Skip to content

Commit

Permalink
scsi/gdth: fix crash in gdth_timeout if no gdth controllers found
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds committed Oct 15, 2007
1 parent f4921af commit c596cc4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/scsi/gdth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c596cc4

Please sign in to comment.