On Fri, Feb 1, 2019 at 5:53 PM Vishal Verma <[email protected]> wrote: > > Static analysis reports that we are leaking 'fp' in the above function. > Add an fclose() to close the leak. > > Signed-off-by: Vishal Verma <[email protected]> > --- > ndctl/util/keys.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/ndctl/util/keys.c b/ndctl/util/keys.c > index 85818c0..acc2ff3 100644 > --- a/ndctl/util/keys.c > +++ b/ndctl/util/keys.c > @@ -260,14 +260,15 @@ static key_serial_t dimm_create_key(struct ndctl_dimm > *dimm, > > wrote = fwrite(buffer, 1, size, fp); > if (wrote != size) { > - if (wrote == -1) > - rc = -errno; > - else > - rc = -EIO; > - fprintf(stderr, "Failed to write to %s: %s\n", > - path, strerror(-rc)); > - free(buffer); > - return rc; > + if (wrote == -1) > + rc = -errno; > + else > + rc = -EIO; > + fprintf(stderr, "Failed to write to %s: %s\n", > + path, strerror(-rc)); > + fclose(fp); > + free(buffer); > + return rc; > } > > fclose(fp);
Reviewed-by: Dan Williams <[email protected]> _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
