From: Dan Carpenter <dan.carpenter@oracle.com>
To: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: Santosh Shilimkar
<santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
Avinash Repaka
<avinash.repaka-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
rds-devel-N0ozoZBvEnrZJqsBc5GL+g@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] RDS: IB: NULL dereference on error in rds_ib_alloc_frmr()
Date: Wed, 14 Jun 2017 13:03:40 +0000 [thread overview]
Message-ID: <20170614130340.ge7dfgttnk4lgnmx@mwanda> (raw)
In-Reply-To: <20170614125423.GA3329@yuvallap>
On Wed, Jun 14, 2017 at 03:54:24PM +0300, Yuval Shaia wrote:
> On Wed, Jun 14, 2017 at 01:39:24PM +0300, Dan Carpenter wrote:
> > We accidentally return ERR_PTR(0) if ib_alloc_mr() fails. The caller
> > is expecting error pointers so it results in a NULL dereference.
> >
> > Fixes: 1659185fb4d0 ("RDS: IB: Support Fastreg MR (FRMR) memory registration mode")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
> > index 48332a6ed738..74a66cc162ed 100644
> > --- a/net/rds/ib_frmr.c
> > +++ b/net/rds/ib_frmr.c
> > @@ -38,7 +38,7 @@ static struct rds_ib_mr *rds_ib_alloc_frmr(struct rds_ib_device *rds_ibdev,
> > struct rds_ib_mr_pool *pool;
> > struct rds_ib_mr *ibmr = NULL;
> > struct rds_ib_frmr *frmr;
> > - int err = 0;
> > + int err;
>
> Can we trust it'll be zero?
We don't ever want it to be zero. This way, hopefully, GCC will catch
it if we introduce any new bugs where we forget to set it to negative.
regards,
dan carpenter
next prev parent reply other threads:[~2017-06-14 13:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-14 10:39 [PATCH] RDS: IB: NULL dereference on error in rds_ib_alloc_frmr() Dan Carpenter
[not found] ` <20170614103924.GK29394-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2017-06-14 12:54 ` Yuval Shaia
2017-06-14 13:03 ` Dan Carpenter [this message]
2017-06-14 13:05 ` Yuval Shaia
2017-06-14 13:05 ` Julia Lawall
2017-06-14 17:18 ` santosh.shilimkar
2017-06-14 20:59 ` Avinash Repaka
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=20170614130340.ge7dfgttnk4lgnmx@mwanda \
--to=dan.carpenter@oracle.com \
--cc=avinash.repaka-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rds-devel-N0ozoZBvEnrZJqsBc5GL+g@public.gmane.org \
--cc=santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox