All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: fix potential NULL pointer dereference.
@ 2014-03-25 12:58 Maurizio Lombardi
  2014-03-25 13:13 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Maurizio Lombardi @ 2014-03-25 12:58 UTC (permalink / raw)
  To: JBottomley; +Cc: linux-scsi, m.lombardi85

The scsi_get_command() function returns NULL if
it fails to allocate the scsi_cmnd structure.
If this happens, a NULL pointer will be dereferenced.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
 drivers/scsi/scsi_error.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 78b004d..4021849 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -2289,6 +2289,9 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
 		return FAILED;
 
 	scmd = scsi_get_command(dev, GFP_KERNEL);
+	if (!scmd)
+		return FAILED;
+
 	blk_rq_init(NULL, &req);
 	scmd->request = &req;
 
-- 
Maurizio Lombardi


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: fix potential NULL pointer dereference.
  2014-03-25 12:58 [PATCH] scsi: fix potential NULL pointer dereference Maurizio Lombardi
@ 2014-03-25 13:13 ` Christoph Hellwig
  2014-03-25 13:30   ` Maurizio Lombardi
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2014-03-25 13:13 UTC (permalink / raw)
  To: Maurizio Lombardi; +Cc: JBottomley, linux-scsi, m.lombardi85

> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 78b004d..4021849 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -2289,6 +2289,9 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
>  		return FAILED;
>  
>  	scmd = scsi_get_command(dev, GFP_KERNEL);
> +	if (!scmd)
> +		return FAILED;
> +

Fails to call scsi_autopm_put_host, or in Jame's latest tree that has
my changes put_device on the sdev gendev.  I sent a correct version
earlier, but there has been very little enthusiasm for it.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: fix potential NULL pointer dereference.
  2014-03-25 13:13 ` Christoph Hellwig
@ 2014-03-25 13:30   ` Maurizio Lombardi
  2014-03-25 15:26     ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Maurizio Lombardi @ 2014-03-25 13:30 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: JBottomley, linux-scsi, m.lombardi85

On Tue, Mar 25, 2014 at 06:13:06AM -0700, Christoph Hellwig wrote:
> > diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> > index 78b004d..4021849 100644
> > --- a/drivers/scsi/scsi_error.c
> > +++ b/drivers/scsi/scsi_error.c
> > @@ -2289,6 +2289,9 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
> >  		return FAILED;
> >  
> >  	scmd = scsi_get_command(dev, GFP_KERNEL);
> > +	if (!scmd)
> > +		return FAILED;
> > +
> 
> Fails to call scsi_autopm_put_host, or in Jame's latest tree that has
> my changes put_device on the sdev gendev.  I sent a correct version
> earlier, but there has been very little enthusiasm for it.
>

Yes you are right, it should call scsi_autopm_put_host before returning.
So if you already have a correct version for it then I drop this patch.

Maurizio.
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: fix potential NULL pointer dereference.
  2014-03-25 13:30   ` Maurizio Lombardi
@ 2014-03-25 15:26     ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2014-03-25 15:26 UTC (permalink / raw)
  To: Maurizio Lombardi; +Cc: Christoph Hellwig, JBottomley, linux-scsi, m.lombardi85

On Tue, Mar 25, 2014 at 02:30:46PM +0100, Maurizio Lombardi wrote:
> Yes you are right, it should call scsi_autopm_put_host before returning.
> So if you already have a correct version for it then I drop this patch.

This was the version I sent out:

http://git.infradead.org/users/hch/scsi.git/commitdiff/245e16e9091f92919c09c8bbae1d982d0717ba22

It's not correct for Jame's current tree as we also need to unwind
getting a reference on sdev_gendev now.  As there's been pushback
against the patch I didn't resubmit it yet, but now that I got my other
changes in the area in it might be worth to try again.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-25 15:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-25 12:58 [PATCH] scsi: fix potential NULL pointer dereference Maurizio Lombardi
2014-03-25 13:13 ` Christoph Hellwig
2014-03-25 13:30   ` Maurizio Lombardi
2014-03-25 15:26     ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.