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

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.