From: "Ewan D. Milne" <emilne@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org,
Himanshu Madhani <hmadhani@marvell.com>,
Quinn Tran <qutran@marvell.com>, Martin Wilck <mwilck@suse.com>,
Daniel Wagner <dwagner@suse.de>,
Roman Bolshakov <r.bolshakov@yadro.com>
Subject: Re: [PATCH] qla2xxx: Fix a NULL pointer dereference in an error path
Date: Tue, 14 Jan 2020 13:13:03 -0500 [thread overview]
Message-ID: <c2baf21f60daf91593bc4a7088427257434e2040.camel@redhat.com> (raw)
In-Reply-To: <086f02b8-b8d8-5336-bf2c-031293d95890@acm.org>
On Mon, 2020-01-13 at 08:11 -0800, Bart Van Assche wrote:
> On 1/13/20 7:29 AM, Ewan D. Milne wrote:
> > On Sun, 2020-01-12 at 13:08 -0800, Bart Van Assche wrote:
> > > diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
> > > index c4e087217484..6560908ed50e 100644
> > > --- a/drivers/scsi/qla2xxx/qla_init.c
> > > +++ b/drivers/scsi/qla2xxx/qla_init.c
> > > @@ -4895,6 +4895,8 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
> > > void
> > > qla2x00_free_fcport(fc_port_t *fcport)
> > > {
> > > + if (!fcport)
> > > + return;
> > > if (fcport->ct_desc.ct_sns) {
> > > dma_free_coherent(&fcport->vha->hw->pdev->dev,
> > > sizeof(struct ct_sns_pkt), fcport->ct_desc.ct_sns,
> > >
> >
> > I would have fixed this by moving the label to be after the qla2x00_free_fcport()
> > call in qla2x00_configure_local_loop(), which Coverity complained about. And
> > called it something different. (The code could probably be simplified by only
> > making a call to qla2x00_alloc_fcport() in one place, something to think about...)
>
> Hi Ewan,
>
> I have considered the solution that you proposed. The solution shown
> above was chosen because I did not want to introduce any memory leaks in
> qla2x00_configure_local_loop(). There is a "goto cleanup_allocation"
> statement in that function that occurs after the "new_fcport =
> qla2x00_alloc_fcport(vha, GFP_KERNEL)" assignment. That is hard to
> notice because the qla2x00_configure_local_loop() function is so long.
>
Yes, but isn't that after "if (new_fcport == NULL)" where the code has
put the previously allocated fcport into the &vha->vp_fcports list and
was unable to allocate another one?
-Ewan
next prev parent reply other threads:[~2020-01-14 18:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-12 21:08 [PATCH] qla2xxx: Fix a NULL pointer dereference in an error path Bart Van Assche
2020-01-13 10:02 ` Daniel Wagner
2020-01-13 15:29 ` Ewan D. Milne
2020-01-13 16:11 ` Bart Van Assche
2020-01-14 18:13 ` Ewan D. Milne [this message]
2020-01-15 2:56 ` Bart Van Assche
2020-01-15 16:08 ` Ewan D. Milne
2020-01-14 10:09 ` Roman Bolshakov
2020-01-18 4:20 Bart Van Assche
2020-01-20 8:58 ` Daniel Wagner
2020-01-20 23:38 ` Martin K. Petersen
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=c2baf21f60daf91593bc4a7088427257434e2040.camel@redhat.com \
--to=emilne@redhat.com \
--cc=bvanassche@acm.org \
--cc=dwagner@suse.de \
--cc=hmadhani@marvell.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mwilck@suse.com \
--cc=qutran@marvell.com \
--cc=r.bolshakov@yadro.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;
as well as URLs for NNTP newsgroup(s).