diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2009-09-23 16:15:35 +0200 |
---|---|---|
committer | Willy Tarreau <w@1wt.eu> | 2012-02-11 15:40:46 +0100 |
commit | 65d2e9804a7ccd7e52321c9f1803afdfbbecad8e (patch) | |
tree | 3f849b4fc8b4f87846cd2789fb77c19b7bf6091e | |
parent | 67cd6ea478c42f9d1f873a7693a91725fd960cba (diff) |
SCSI: scsi_lib: fix potential NULL dereference
commit 03b147083a2f9a2a3fbbd2505fa88ffa3c6ab194 upstream.
Stanse found a potential NULL dereference in scsi_kill_request.
Instead of triggering BUG() in 'if (unlikely(cmd == NULL))' branch,
the kernel will Oops earlier on cmd dereference.
Move the dereferences after the if.
[ WT: starget is not set in 2.6.27 ]
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Willy Tarreau <w@1wt.eu>
-rw-r--r-- | drivers/scsi/scsi_lib.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 9899f6e4c5e..88ed1eea273 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1389,8 +1389,8 @@ static inline int scsi_host_queue_ready(struct request_queue *q, static void scsi_kill_request(struct request *req, struct request_queue *q) { struct scsi_cmnd *cmd = req->special; - struct scsi_device *sdev = cmd->device; - struct Scsi_Host *shost = sdev->host; + struct scsi_device *sdev; + struct Scsi_Host *shost; blkdev_dequeue_request(req); @@ -1402,6 +1402,8 @@ static void scsi_kill_request(struct request *req, struct request_queue *q) scmd_printk(KERN_INFO, cmd, "killing request\n"); + sdev = cmd->device; + shost = sdev->host; scsi_init_cmd_errh(cmd); cmd->result = DID_NO_CONNECT << 16; atomic_inc(&cmd->device->iorequest_cnt); |