]> err.no Git - linux-2.6/commitdiff
scsi/gdth: fix crash in gdth_timeout if no gdth controllers found
authorLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 15 Oct 2007 19:46:16 +0000 (12:46 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 15 Oct 2007 19:46:16 +0000 (12:46 -0700)
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>
drivers/scsi/gdth.c

index e8010a702e73c6a0c33d0cadbe624b5c8d89947e..3ac080ee6e2f2785230259e595d39d806ebeed26 100644 (file)
@@ -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);