f1140bd
From 3ae8633ef90fb6c0da7df88ffc08dc1f74efeb66 Mon Sep 17 00:00:00 2001
6a91557
From: "kernel-team@fedoraproject.org" <kernel-team@fedoraproject.org>
6a91557
Date: Fri, 10 Feb 2012 14:56:13 -0500
6a91557
Subject: [PATCH] scsi: sd_revalidate_disk prevent NULL ptr deref
6a91557
68d0d67
Bugzilla: 754518
68d0d67
Upstream-status: Fedora mustard (might be worth dropping...)
6a91557
---
6a91557
 drivers/scsi/sd.c | 7 ++++++-
6a91557
 1 file changed, 6 insertions(+), 1 deletion(-)
3f7b3ae
3f7b3ae
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
3f7b3ae
index 2c2041ca4b70..e10812d985af 100644
3f7b3ae
--- a/drivers/scsi/sd.c
3f7b3ae
+++ b/drivers/scsi/sd.c
3f7b3ae
@@ -2749,13 +2749,18 @@ static int sd_try_extended_inquiry(struct scsi_device *sdp)
af1af57
 static int sd_revalidate_disk(struct gendisk *disk)
af1af57
 {
af1af57
 	struct scsi_disk *sdkp = scsi_disk(disk);
af1af57
-	struct scsi_device *sdp = sdkp->device;
af1af57
+	struct scsi_device *sdp;
af1af57
 	unsigned char *buffer;
3f7b3ae
 	unsigned int max_xfer;
af1af57
 
af1af57
 	SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
af1af57
 				      "sd_revalidate_disk\n"));
af1af57
 
7505efc
+	if (WARN_ONCE((!sdkp), "Invalid scsi_disk from %p\n", disk))
af1af57
+		goto out;
af1af57
+
af1af57
+	sdp = sdkp->device;
af1af57
+
af1af57
 	/*
af1af57
 	 * If the device is offline, don't try and read capacity or any
af1af57
 	 * of the other niceties.
6a91557
-- 
6a91557
1.9.3
6a91557