public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Colin King <colin.king@canonical.com>
Cc: Moni Shoua <monis@mellanox.com>,
	Doug Ledford <dledford@redhat.com>,
	Sean Hefty <sean.hefty@intel.com>,
	Hal Rosenstock <hal.rosenstock@gmail.com>,
	linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] IB/rxe: check for allocation failure on elem
Date: Tue, 12 Sep 2017 17:48:29 +0300	[thread overview]
Message-ID: <20170912144829.GR3405@mtr-leonro.local> (raw)
In-Reply-To: <20170909125607.GA22465@mtr-leonro.local>

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

On Sat, Sep 09, 2017 at 03:56:07PM +0300, Leon Romanovsky wrote:
> On Fri, Sep 08, 2017 at 03:37:45PM +0100, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > The allocation for elem may fail (especially because we're using
> > GFP_ATOMIC) so best to check for a null return.  This fixes a potential
> > null pointer dereference when assigning elem->pool.
> >
> > Detected by CoverityScan CID#1357507 ("Dereference null return value")
> >
> > Fixes: 8700e3e7c485 ("Soft RoCE driver")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/infiniband/sw/rxe/rxe_pool.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
> > index c1b5f38f31a5..3b4916680018 100644
> > --- a/drivers/infiniband/sw/rxe/rxe_pool.c
> > +++ b/drivers/infiniband/sw/rxe/rxe_pool.c
> > @@ -404,6 +404,8 @@ void *rxe_alloc(struct rxe_pool *pool)
> >  	elem = kmem_cache_zalloc(pool_cache(pool),
> >  				 (pool->flags & RXE_POOL_ATOMIC) ?
> >  				 GFP_ATOMIC : GFP_KERNEL);
> > +	if (!elem)
> > +		return NULL;
> >
>
> It is not enough to simply return NULL, you also should release "pool" too.

Colin,
do you plan to fix the comment and resend it?

Thanks

>
> Thanks
>
> >  	elem->pool = pool;
> >  	kref_init(&elem->ref_cnt);
> > --
> > 2.14.1
> >



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

  reply	other threads:[~2017-09-13 12:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-08 14:37 [PATCH] IB/rxe: check for allocation failure on elem Colin King
2017-09-09 12:56 ` Leon Romanovsky
2017-09-12 14:48   ` Leon Romanovsky [this message]
2017-10-09 13:16     ` Doug Ledford
2017-10-09 13:18       ` Colin Ian King
2017-10-09 16:13         ` Doug Ledford
2017-10-09 13:43       ` 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=20170912144829.GR3405@mtr-leonro.local \
    --to=leon@kernel.org \
    --cc=colin.king@canonical.com \
    --cc=dledford@redhat.com \
    --cc=hal.rosenstock@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=monis@mellanox.com \
    --cc=sean.hefty@intel.com \
    /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