summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/gdth.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-15 21:46:16 +0200
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-15 21:46:16 +0200
commitc596cc46ba1c5769866efe586daff3422bc31afe (patch)
tree080f0fc2fc91d6b37f1cf2992bab3d6720c748e1 /drivers/scsi/gdth.c
parentMerge git://git.linux-nfs.org/pub/linux/nfs-2.6 (diff)
downloadlinux-c596cc46ba1c5769866efe586daff3422bc31afe.tar.xz
linux-c596cc46ba1c5769866efe586daff3422bc31afe.zip
scsi/gdth: fix crash in gdth_timeout if no gdth controllers found
If the gdth module is loaded (or compiled in), the gdth_timeout function gets started even if no actual gdth controllers are found b the probing. That ends up not only being unnecessary, but also causes a crash due to the function blindly just trying to pick the first entry off the "gdth_instances" list, and accessing it - which obviously doesn't work if the list is empty! Noticed by Ingo Molnar. Tested-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to '')
-rw-r--r--drivers/scsi/gdth.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index e8010a702e73..3ac080ee6e2f 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -5213,6 +5213,10 @@ static int __init gdth_init(void)
#endif /* CONFIG_PCI */
TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count));
+
+ if (list_empty(&gdth_instances))
+ return -ENODEV;
+
#ifdef GDTH_STATISTICS
TRACE2(("gdth_detect(): Initializing timer !\n"));
init_timer(&gdth_timer);