kernel/scsi-sd_revalidate_disk-prevent-NULL-ptr-deref.patch

35 lines
1.0 KiB
Diff
Raw Normal View History

From: "kernel-team@fedoraproject.org" <kernel-team@fedoraproject.org>
Date: Fri, 10 Feb 2012 14:56:13 -0500
Subject: [PATCH] scsi: sd_revalidate_disk prevent NULL ptr deref
Bugzilla: 754518
Upstream-status: Fedora mustard (might be worth dropping...)
---
drivers/scsi/sd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
2014-08-08 09:42:06 +00:00
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
2015-06-26 13:33:38 +00:00
index 3b2fcb4fada0..f0f9e8574303 100644
2014-08-08 09:42:06 +00:00
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2717,13 +2717,18 @@ static int sd_try_extended_inquiry(struct scsi_device *sdp)
static int sd_revalidate_disk(struct gendisk *disk)
{
struct scsi_disk *sdkp = scsi_disk(disk);
- struct scsi_device *sdp = sdkp->device;
+ struct scsi_device *sdp;
unsigned char *buffer;
2014-08-08 09:42:06 +00:00
unsigned int max_xfer;
SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
"sd_revalidate_disk\n"));
+ if (WARN_ONCE((!sdkp), "Invalid scsi_disk from %p\n", disk))
+ goto out;
+
+ sdp = sdkp->device;
+
/*
* If the device is offline, don't try and read capacity or any
* of the other niceties.