From: Peter Teoh
Date: Fri, 7 Mar 2008 20:53:49 +0000 (+0100)
Subject: ide: fix buggy code in ide_register_hw()
X-Git-Tag: v2.6.25-rc5~10^2~2
X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c6025d44448bd688dfd351a09bc620aafa4d1ff;p=linux-2.6
ide: fix buggy code in ide_register_hw()
Relocating the index to come after finding the hwif pointer.
Signed-off-by: Peter Teoh
Reported-by: Adrian Bunk
Signed-off-by: Bartlomiej Zolnierkiewicz
---
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index fa16bc30bb..c2b7912240 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -667,7 +667,6 @@ int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
do {
hwif = ide_deprecated_find_port(hw->io_ports[IDE_DATA_OFFSET]);
- index = hwif->index;
if (hwif)
goto found;
for (index = 0; index < MAX_HWIFS; index++)
@@ -675,6 +674,7 @@ int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
} while (retry--);
return -1;
found:
+ index = hwif->index;
if (hwif->present)
ide_unregister(index, 0, 1);
else if (!hwif->hold)