linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: <linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Cc: <torvalds@linux-foundation.org>, <akpm@linux-foundation.org>,
	<alan@lxorguk.ukuu.org.uk>, Jiri Slaby <jirislaby@gmail.com>,
	James Bottomley <James.Bottomley@suse.de>
Subject: [19/27] SCSI: scsi_lib: fix potential NULL dereference
Date: Wed, 07 Dec 2011 08:54:52 -0800	[thread overview]
Message-ID: <20111207165602.002157755@clark.kroah.org> (raw)
In-Reply-To: <20111207165611.GA19872@kroah.com>

2.6.32-longterm review patch.  If anyone has any objections, please let me know.

------------------

From: Jiri Slaby <jirislaby@gmail.com>

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.

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>

---
 drivers/scsi/scsi_lib.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1370,9 +1370,9 @@ static int scsi_lld_busy(struct request_
 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_target *starget = scsi_target(sdev);
-	struct Scsi_Host *shost = sdev->host;
+	struct scsi_device *sdev;
+	struct scsi_target *starget;
+	struct Scsi_Host *shost;
 
 	blk_start_request(req);
 
@@ -1382,6 +1382,9 @@ static void scsi_kill_request(struct req
 		BUG();
 	}
 
+	sdev = cmd->device;
+	starget = scsi_target(sdev);
+	shost = sdev->host;
 	scsi_init_cmd_errh(cmd);
 	cmd->result = DID_NO_CONNECT << 16;
 	atomic_inc(&cmd->device->iorequest_cnt);



  parent reply	other threads:[~2011-12-07 17:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07 16:56 [00/27] 2.6.32.50-longterm review Greg KH
2011-12-07 16:54 ` [01/27] i2c-algo-bit: Generate correct i2c address sequence for 10-bit target Greg KH
2011-12-07 16:54 ` [02/27] eCryptfs: Extend array bounds for all filename chars Greg KH
2011-12-07 16:54 ` [03/27] PCI hotplug: shpchp: dont blindly claim non-AMD 0x7450 device IDs Greg KH
2011-12-07 16:54 ` [04/27] ARM: 7161/1: errata: no automatic store buffer drain Greg KH
2011-12-07 16:54 ` [05/27] ALSA: lx6464es - fix device communication via command bus Greg KH
2011-12-07 17:13   ` Tim Blechmann
2011-12-07 16:54 ` [06/27] SUNRPC: Ensure we return EAGAIN in xs_nospace if congestion is cleared Greg KH
2011-12-07 16:54 ` [07/27] timekeeping: add arch_offset hook to ktime_get functions Greg KH
2011-12-07 16:54 ` [08/27] p54spi: Add missing spin_lock_init Greg KH
2011-12-07 16:54 ` [09/27] p54spi: Fix workqueue deadlock Greg KH
2011-12-07 16:54 ` [10/27] nl80211: fix MAC address validation Greg KH
2011-12-07 16:54 ` [11/27] gro: reset vlan_tci on reuse Greg KH
2011-12-07 16:54 ` [12/27] staging: usbip: bugfix for deadlock Greg KH
2011-12-07 16:54 ` [13/27] staging: comedi: fix oops for USB DAQ devices Greg KH
2011-12-07 16:54 ` [14/27] Staging: comedi: fix signal handling in read and write Greg KH
2011-12-07 16:54 ` [15/27] USB: whci-hcd: fix endian conversion in qset_clear() Greg KH
2011-12-07 16:54 ` [16/27] usb: ftdi_sio: add PID for Propox ISPcable III Greg KH
2011-12-07 16:54 ` [17/27] usb: option: add SIMCom SIM5218 Greg KH
2011-12-07 16:54 ` [18/27] USB: usb-storage: unusual_devs entry for Kingston DT 101 G2 Greg KH
2011-12-07 16:54 ` Greg KH [this message]
2011-12-07 16:54 ` [20/27] SCSI: Silencing killing requests for dead queue Greg KH
2011-12-07 16:54 ` [21/27] cifs: fix cifs stable patch cifs-fix-oplock-break-handling-try-2.patch Greg KH
2011-12-07 16:54 ` [22/27] sched, x86: Avoid unnecessary overflow in sched_clock Greg KH
2011-12-07 16:54 ` [23/27] x86/mpparse: Account for bus types other than ISA and PCI Greg KH
2011-12-07 16:54 ` [24/27] oprofile, x86: Fix crash when unloading module (nmi timer mode) Greg KH
2011-12-07 16:54 ` [25/27] genirq: Fix race condition when stopping the irq thread Greg KH
2011-12-07 16:54 ` [26/27] tick-broadcast: Stop active broadcast device when replacing it Greg KH
2011-12-07 16:55 ` [27/27] clockevents: Set noop handler in clockevents_exchange_device() Greg KH
2011-12-29 12:09   ` Jonathan Nieder
2011-12-30  1:05     ` Linus Torvalds
2011-12-30 15:07       ` Tim Gardner
     [not found]         ` <CA++bM2uqcWFM6=WdmrusmugQw2nH_KDyySKH+1qyr8GK0Cq14A@mail.gmail.com>
2012-01-05 10:27           ` Feng Tang
2012-01-10 14:23       ` Thomas Gleixner

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=20111207165602.002157755@clark.kroah.org \
    --to=gregkh@suse.de \
    --cc=James.Bottomley@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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).