Skip to contentSkip to conversation

rdma: Avoid memory leak for skipper resource

PATCH Applied Leon Romanovsky 2 participants 2 messages Feb 20, 2018 – Feb 23, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rdma: Avoid memory leak for skipper resource

From: Leon Romanovsky <[email protected]>

The call to get_task_name() allocates memory which is not freed in case of skipping the object.

Fixes 8ecac46a60ff ("rdma: Add QP resource tracking information")
---
 rdma/res.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
rdma/res.c +3 -1
index 2a63e712..62f5c544 100644
@@ -395,8 +395,10 @@ static int res_qp_parse_cb(const struct nlmsghdr *nlh, void *data)
 			comm = get_task_name(pid);
 		}
 
-		if (rd_check_is_filtered(rd, "pid", pid))
+		if (rd_check_is_filtered(rd, "pid", pid)) {
+			free(comm);
 			continue;
+		}
 
 		if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
 			/* discard const from mnl_attr_get_str */

--
2.16.1