Blame scsi-sd_revalidate_disk-prevent-NULL-ptr-deref.patch
|
|
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
|
|
|
a281db6 |
index 6b78476d04bb..d490145a317d 100644
|
|
|
3f7b3ae |
--- a/drivers/scsi/sd.c
|
|
|
3f7b3ae |
+++ b/drivers/scsi/sd.c
|
|
|
208228c |
@@ -2750,13 +2750,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 |
--
|
|
|
1e63a38 |
2.1.0
|
|
|
6a91557 |
|