ide: fix buggy code in ide_register_hw()
authorPeter Teoh <htmldeveloper@gmail.com>
Fri, 7 Mar 2008 20:53:49 +0000 (21:53 +0100)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Fri, 7 Mar 2008 20:53:49 +0000 (21:53 +0100)
Relocating the index to come after finding the hwif pointer.

Signed-off-by: Peter Teoh <htmldeveloper@gmail.com>
Reported-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/ide.c

index fa16bc30bbc985efe4efc4ad9c91d93b3d7b0ed7..c2b791224097e95a6c71bcde41cba974b8854894 100644 (file)
@@ -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)