netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	David Ahern <dsahern@gmail.com>, netdev <netdev@vger.kernel.org>
Subject: [PATCH iproute2] rdma: Avoid memory leak for skipper resource
Date: Tue, 20 Feb 2018 14:47:18 +0200	[thread overview]
Message-ID: <20180220124718.16750-1-leon@kernel.org> (raw)

From: Leon Romanovsky <leonro@mellanox.com>

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")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 rdma/res.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rdma/res.c b/rdma/res.c
index 2a63e712..62f5c544 100644
--- a/rdma/res.c
+++ b/rdma/res.c
@@ -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

             reply	other threads:[~2018-02-20 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 12:47 Leon Romanovsky [this message]
2018-02-23 16:43 ` [PATCH iproute2] rdma: Avoid memory leak for skipper resource Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180220124718.16750-1-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=leonro@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).