In add_dax_region(), region->devname is allocated by calling strdup(), which may return NULL. So, we need to check whether region->devname is NULL, and free region->devname in err_read tag.
Signed-off-by: Zhiqiang Liu <[email protected]> --- daxctl/lib/libdaxctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c index ee4a069..d841b78 100644 --- a/daxctl/lib/libdaxctl.c +++ b/daxctl/lib/libdaxctl.c @@ -287,6 +287,8 @@ static struct daxctl_region *add_dax_region(void *parent, int id, region->refcount = 1; list_head_init(®ion->devices); region->devname = strdup(devpath_to_devname(base)); + if (!region->devname) + goto err_read; sprintf(path, "%s/%s/size", base, attrs); if (sysfs_read_attr(ctx, path, buf) == 0) @@ -314,6 +316,7 @@ static struct daxctl_region *add_dax_region(void *parent, int id, err_read: free(region->region_buf); free(region->region_path); + free(region->devname); free(region); err_region: free(path); -- 1.8.3.1 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
