Skip to contentSkip to conversation

libcxl: Fix memory leakage in cxl_port_init()

PATCH Applied Shivaprasad G Bhat 3 participants 3 messages Jul 18, 2022 – Jul 19, 2022 libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libcxl: Fix memory leakage in cxl_port_init()

The local variable 'path' is not freed in cxl_port_init() for success case. The patch fixes that.

---
 cxl/lib/libcxl.c |    1 +
 1 file changed, 1 insertion(+)
cxl/lib/libcxl.c +1 -0
index be6bc2c..e52896f 100644
@@ -770,6 +770,7 @@ static int cxl_port_init(struct cxl_port *port, struct cxl_port *parent_port,
 	if (sysfs_read_attr(ctx, path, buf) == 0)
 		port->module = util_modalias_to_module(ctx, buf);
 
+	free(path);
 	return 0;
 err:
 	free(port->dev_path);
maintainer Applied
#2 lore raw
In reply to Shivaprasad G Bhat
Quoted 17 lines · Shivaprasad G Bhat

The local variable 'path' is not freed in cxl_port_init() for success case.
The patch fixes that.

---
 cxl/lib/libcxl.c |    1 +

 1 file changed, 1 insertion(+)
cxl/lib/libcxl.c +0 -0
index be6bc2c..e52896f 100644
@@ -770,6 +770,7 @@ static int cxl_port_init(struct cxl_port *port,
 struct cxl_port *parent_port,
         if (sysfs_read_attr(ctx, path, buf) == 0)
                 port->module = util_modalias_to_module(ctx, buf);
Quoted 7 lines


+       free(path);
        return 0;
 err:
        free(port->dev_path);

Thanks, applied.
Just a quick note to CC [email protected] for CXL related patches, and use "ndctl PATCH" as the subject prefix.