Message ID | 1459782600-16073-2-git-send-email-ian.jackson@eu.citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>>> On 4/4/2016 at 11:10 PM, in message <1459782600-16073-2-git-send-email-ian.jackson@eu.citrix.com>, Ian Jackson <ian.jackson@eu.citrix.com> wrote: > Bug introduced in bc023ecd > "libxl_utils: add internal function to read sysfs file contents" > > CID: 1358108 > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> > CC: coverity@xenproject.org > CC: Chunyan Liu <cyliu@suse.com> > --- > tools/libxl/libxl_utils.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c > index ceb8825..bd58a52 100644 > --- a/tools/libxl/libxl_utils.c > +++ b/tools/libxl/libxl_utils.c > @@ -466,6 +466,7 @@ int libxl__read_sysfs_file_contents(libxl__gc *gc, const > char *filename, > e = errno; > assert(e != ENOENT); > if (f) fclose(f); > + free(data); 'data' is malloced with 'gc', it'll be freed by GC_FREE. Do we need to free it here? Chunyan > return e; > } >
Chun Yan Liu writes ("Re: [PATCH 2/2] libxl: Do not leak data on error path from libxl__read_sysfs_file_contents"): > <1459782600-16073-2-git-send-email-ian.jackson@eu.citrix.com>, Ian Jackson > <ian.jackson@eu.citrix.com> wrote: > > + free(data); > > 'data' is malloced with 'gc', it'll be freed by GC_FREE. Do we need to free > it here? Oh, you are quite right. My patch was wrong. Thanks, Ian.
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index ceb8825..bd58a52 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -466,6 +466,7 @@ int libxl__read_sysfs_file_contents(libxl__gc *gc, const char *filename, e = errno; assert(e != ENOENT); if (f) fclose(f); + free(data); return e; }
Bug introduced in bc023ecd "libxl_utils: add internal function to read sysfs file contents" CID: 1358108 Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> CC: coverity@xenproject.org CC: Chunyan Liu <cyliu@suse.com> --- tools/libxl/libxl_utils.c | 1 + 1 file changed, 1 insertion(+)