Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
From: Doug Ledford <dledford@redhat.com>
To: Bernard Metzler <BMT@zurich.ibm.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
	linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v2] RDMA/siw: Fix a memory leak in siw_init_cpulist()
Date: Mon, 12 Aug 2019 10:53:36 -0400
Message-ID: <35d646ab61f2b81b382c8638c0d43ab2188d8c2b.camel@redhat.com> (raw)
In-Reply-To: <OFD09B6B8D.A208B8E7-ON00258451.004F8BA4-00258451.004F8BAA@notes.na.collabserv.com>

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

On Fri, 2019-08-09 at 14:28 +0000, Bernard Metzler wrote:
> -----"Dan Carpenter" <dan.carpenter@oracle.com> wrote: -----
> 
> > To: "Bernard Metzler" <bmt@zurich.ibm.com>
> > From: "Dan Carpenter" <dan.carpenter@oracle.com>
> > Date: 08/09/2019 04:09PM
> > Cc: "Doug Ledford" <dledford@redhat.com>, "Jason Gunthorpe"
> > <jgg@ziepe.ca>, linux-rdma@vger.kernel.org,
> > kernel-janitors@vger.kernel.org
> > Subject: [EXTERNAL] [PATCH v2] RDMA/siw: Fix a memory leak in
> > siw_init_cpulist()
> > 
> > The error handling code doesn't free siw_cpu_info.tx_valid_cpus[0].
> > The
> > first iteration through the loop is a no-op so this is sort of an
> > off
> > by one bug.  Also Bernard pointed out that we can remove the NULL
> > assignment and simplify the code a bit.
> > 
> > Fixes: bdcf26bf9b3a ("rdma/siw: network and RDMA core interface")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
> > ---
> > v2:  Remove the NULL assignment like Bernard Metzler pointed out.
> > 
> > drivers/infiniband/sw/siw/siw_main.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/drivers/infiniband/sw/siw/siw_main.c
> > b/drivers/infiniband/sw/siw/siw_main.c
> > index d0f140daf659..05a92f997f60 100644
> > --- a/drivers/infiniband/sw/siw/siw_main.c
> > +++ b/drivers/infiniband/sw/siw/siw_main.c
> > @@ -160,10 +160,8 @@ static int siw_init_cpulist(void)
> > 
> > out_err:
> > 	siw_cpu_info.num_nodes = 0;
> > -	while (i) {
> > +	while (--i >= 0)
> > 		kfree(siw_cpu_info.tx_valid_cpus[i]);
> > -		siw_cpu_info.tx_valid_cpus[i--] = NULL;
> > -	}
> > 	kfree(siw_cpu_info.tx_valid_cpus);
> > 	siw_cpu_info.tx_valid_cpus = NULL;
> > 
> > -- 
> > 2.20.1
> > 
> > 
> 
> Dan, many thanks for finding and fixing this!
> 
> 
> Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
> 

Thanks, applied to for-rc.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
    Fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 10:16 [PATCH] " Dan Carpenter
2019-08-09 11:44 ` Bernard Metzler
2019-08-09 11:59   ` Dan Carpenter
2019-08-09 14:09   ` [PATCH v2] " Dan Carpenter
2019-08-09 14:28     ` Bernard Metzler
2019-08-12 14:53       ` Doug Ledford [this message]

Reply instructions:

You may reply publically 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=35d646ab61f2b81b382c8638c0d43ab2188d8c2b.camel@redhat.com \
    --to=dledford@redhat.com \
    --cc=BMT@zurich.ibm.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jgg@ziepe.ca \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.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

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org linux-rdma@archiver.kernel.org
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/ public-inbox