Commit 1a03ae0f authored by Michael Reed's avatar Michael Reed Committed by James Bottomley

[SCSI] sd name space exhaustion causes system hang

Following a site power outage which re-enabled all the ports on my FC
switches, my system subsequently booted with far too many luns!  I had
let it run hoping it would make multi-user.  It didn't.  :(  It hung solid
after exhausting the last sd device, sdzzz, and attempting to create sdaaaa
and beyond.  I was unable to get a dump.

Discovered using a 2.6.32.13 based system.

correct this by detecting when the last index is utilized and failing
the sd probe of the device.  Patch applies to scsi-misc-2.6.
Signed-off-by: default avatarMichael Reed <mdr@sgi.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 43ca910a
...@@ -2288,11 +2288,10 @@ static void sd_probe_async(void *data, async_cookie_t cookie) ...@@ -2288,11 +2288,10 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
index = sdkp->index; index = sdkp->index;
dev = &sdp->sdev_gendev; dev = &sdp->sdev_gendev;
if (index < SD_MAX_DISKS) { gd->major = sd_major((index & 0xf0) >> 4);
gd->major = sd_major((index & 0xf0) >> 4); gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); gd->minors = SD_MINORS;
gd->minors = SD_MINORS;
}
gd->fops = &sd_fops; gd->fops = &sd_fops;
gd->private_data = &sdkp->driver; gd->private_data = &sdkp->driver;
gd->queue = sdkp->device->request_queue; gd->queue = sdkp->device->request_queue;
...@@ -2382,6 +2381,12 @@ static int sd_probe(struct device *dev) ...@@ -2382,6 +2381,12 @@ static int sd_probe(struct device *dev)
if (error) if (error)
goto out_put; goto out_put;
if (index >= SD_MAX_DISKS) {
error = -ENODEV;
sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name space exhausted.\n");
goto out_free_index;
}
error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN); error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN);
if (error) if (error)
goto out_free_index; goto out_free_index;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment