From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Ruhl, Michael J" <michael.j.ruhl@intel.com>
Cc: "Marciniszyn, Mike" <mike.marciniszyn@intel.com>,
"Dalessandro, Dennis" <dennis.dalessandro@intel.com>,
Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] IB/hfi1: Prevent a NULL dereference
Date: Tue, 9 Jan 2018 17:23:38 +0300 [thread overview]
Message-ID: <20180109142338.f7242rjtqffogwop@mwanda> (raw)
In-Reply-To: <14063C7AD467DE4B82DEDB5C278E8663A9F7F391@fmsmsx107.amr.corp.intel.com>
On Tue, Jan 09, 2018 at 02:16:59PM +0000, Ruhl, Michael J wrote:
> > -----Original Message-----
> > From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> > Sent: Tuesday, January 9, 2018 4:27 AM
> > To: Marciniszyn, Mike <mike.marciniszyn@intel.com>; Ruhl, Michael J
> > <michael.j.ruhl@intel.com>
> > Cc: Dalessandro, Dennis <dennis.dalessandro@intel.com>; Doug Ledford
> > <dledford@redhat.com>; Jason Gunthorpe <jgg@ziepe.ca>; linux-
> > rdma@vger.kernel.org; kernel-janitors@vger.kernel.org
> > Subject: [PATCH] IB/hfi1: Prevent a NULL dereference
> >
> > In the original code, we set "fd->uctxt" to NULL and then dereference it
> > which will cause an Oops.
> >
> > Fixes: f2a3bc00a03c ("IB/hfi1: Protect context array set/clear with spinlock")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/drivers/infiniband/hw/hfi1/file_ops.c
> > b/drivers/infiniband/hw/hfi1/file_ops.c
> > index 82086241aac3..3de1ac94bb85 100644
> > --- a/drivers/infiniband/hw/hfi1/file_ops.c
> > +++ b/drivers/infiniband/hw/hfi1/file_ops.c
> > @@ -763,10 +763,10 @@ static int complete_subctxt(struct hfi1_filedata *fd)
> > }
> >
> > if (ret) {
> > + __clear_bit(fd->subctxt, fd->uctxt->in_use_ctxts);
> > hfi1_rcd_put(fd->uctxt);
> > fd->uctxt = NULL;
> > spin_lock_irqsave(&fd->dd->uctxt_lock, flags);
> > - __clear_bit(fd->subctxt, fd->uctxt->in_use_ctxts);
> > spin_unlock_irqrestore(&fd->dd->uctxt_lock, flags);
> > }
> >
>
> Hi Dan,
>
> Thanks for catching this.
>
> However, the patch is not quite correct.
>
> The __clear_bit() spin_lock_irqsave/restore need stay together. The patch should be:
>
Oh. Yeah. I should have noticed that now the spin_lock is pointless.
Let me resend. Thanks.
regards,
dan carpenter
next prev parent reply other threads:[~2018-01-09 14:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 9:27 [PATCH] IB/hfi1: Prevent a NULL dereference Dan Carpenter
2018-01-09 14:02 ` Dennis Dalessandro
2018-01-09 14:16 ` Ruhl, Michael J
2018-01-09 14:23 ` Dan Carpenter [this message]
[not found] ` <14063C7AD467DE4B82DEDB5C278E8663A9F7F391-96pTJSsuoYRzLByeVOV5+bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2018-01-09 20:03 ` [PATCH v2] " Dan Carpenter
2018-01-09 20:39 ` Ruhl, Michael J
2018-01-10 22:03 ` Doug Ledford
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=20180109142338.f7242rjtqffogwop@mwanda \
--to=dan.carpenter@oracle.com \
--cc=dennis.dalessandro@intel.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=michael.j.ruhl@intel.com \
--cc=mike.marciniszyn@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