All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: 'David Ahern' <dsahern-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Steve Wise
	<swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>,
	'RDMA mailing list'
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	'Stephen Hemminger'
	<stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
Subject: Re: [PATCH iproute2-next 08/10] rdma: Add QP resource tracking information
Date: Mon, 5 Feb 2018 16:00:37 +0200	[thread overview]
Message-ID: <20180205140037.GF2567@mtr-leonro.local> (raw)
In-Reply-To: <20180205132231.GD2567-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1993 bytes --]

On Mon, Feb 05, 2018 at 03:22:31PM +0200, Leon Romanovsky wrote:
> On Thu, Feb 01, 2018 at 02:05:08PM -0600, Steve Wise wrote:
> > Hey Leon,
>
> <...>
>
> >
> > > +static int res_qp_parse_cb(const struct nlmsghdr *nlh, void *data)
> > > +{
>
> <...>
>
> > > +
> > > +	mnl_attr_for_each_nested(nla_entry, nla_table) {
> > > +		struct nlattr *nla_line[RDMA_NLDEV_ATTR_MAX] = {};
> > > +		uint32_t lqpn, rqpn = 0, rq_psn = 0, sq_psn;
> > > +		uint8_t type, state, path_mig_state = 0;
> > > +		uint32_t port = 0, pid = 0;
> > > +		char *comm = NULL;
>
> <...>
>
> > > +
> > > +		if (rd_check_is_filtered(rd, "pid", pid))
> > > +			continue;
> >
> > Is comm leaked here when ATTR_RES_PID is present?
> >
> >
> > > +
> > > +		if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
> > > +			/* discard const from mnl_attr_get_str */
> > > +			comm = (char
> > > *)mnl_attr_get_str(nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
> >
> > And also here if the kernel ever passes up both PID and KERN_NAME (which it
> > isn't supposed to).
>
> Yes, you are right, and the bad thing that I prepared everything to call
> free() unconditionally by setting comm to be NULL.

Stephen, David,

How do you want me to proceed?

The actual change is pretty minor:

diff --git a/rdma/res.c b/rdma/res.c
index 2a63e712..31d0c4a7 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 */
@@ -420,8 +422,7 @@ static int res_qp_parse_cb(const struct nlmsghdr *nlh, void *data)
 		print_pid(rd, pid);
 		print_comm(rd, comm, nla_line);

-		if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
-			free(comm);
+		free(comm);

 		if (rd->json_output)
 			jsonw_end_array(rd->jw);

>
> Thanks
>
> >
> >
> > Steve.
> >



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2018-02-05 14:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-31  8:11 [PATCH iproute2-next 00/10] RDMA resource tracking Leon Romanovsky
2018-01-31  8:11 ` [PATCH iproute2-next 01/10] rdma: Add option to provide "-" sign for the port number Leon Romanovsky
2018-01-31  8:11 ` [PATCH iproute2-next 02/10] rdma: Make visible the number of arguments Leon Romanovsky
2018-01-31  8:11 ` [PATCH iproute2-next 04/10] rdma: Set pointer to device name position Leon Romanovsky
2018-01-31  8:11 ` [PATCH iproute2-next 05/10] rdma: Allow external usage of compare string routine Leon Romanovsky
2018-01-31  8:11 ` [PATCH iproute2-next 06/10] rdma: Update kernel header file Leon Romanovsky
2018-01-31  8:11 ` [PATCH iproute2-next 09/10] rdma: Document resource tracking Leon Romanovsky
2018-01-31  8:11 ` [PATCH iproute2-next 10/10] rdma: Check return value of strdup call Leon Romanovsky
     [not found] ` <20180131081156.19607-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-31  8:11   ` [PATCH iproute2-next 03/10] rdma: Add filtering infrastructure Leon Romanovsky
2018-01-31  8:11   ` [PATCH iproute2-next 07/10] rdma: Add resource tracking summary Leon Romanovsky
2018-01-31  8:11   ` [PATCH iproute2-next 08/10] rdma: Add QP resource tracking information Leon Romanovsky
     [not found]     ` <20180131081156.19607-9-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-02-01 20:05       ` Steve Wise
2018-02-05 13:22         ` Leon Romanovsky
     [not found]           ` <20180205132231.GD2567-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2018-02-05 14:00             ` Leon Romanovsky [this message]
     [not found]               ` <20180205140037.GF2567-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2018-02-05 16:21                 ` David Ahern
2018-01-31  8:17   ` [PATCH iproute2-next 00/10] RDMA resource tracking Leon Romanovsky
2018-02-06  1:25   ` Stephen Hemminger
2018-02-06  7:29     ` Leon Romanovsky

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=20180205140037.GF2567@mtr-leonro.local \
    --to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=dsahern-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org \
    --cc=swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.