Skip to contentSkip to conversation

ide-generic: Fix no initalization of idx in some case

PATCH In review Johann Felix Soden 2 participants 2 messages Feb 20, 2008 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ide-generic: Fix no initalization of idx in some case

From: Johann Felix Soden <[email protected]>

If the slot is already occupied, there should be written 0xff to idx[i]. In the ongoing code and in this case there are no writings to idx[i], so garbage stays in idx. The kernel get into a endless loop printing:

: I/O resource 0x0-0x0 not free.
Trying to free nonexistent resource <0000000000000000-0000000000000000> Trying to free nonexistent resource <0000000000000000-0000000000000000>

This patch solves http://article.gmane.org/gmane.linux.ide/28810 .

---
 drivers/ide/ide-generic.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/ide/ide-generic.c +3 -0
index 5499a77..fb9865c 100644
@@ -103,7 +103,10 @@ static int __init ide_generic_init(void)
 			 */
 			hwif = ide_find_port();
 			if (hwif == NULL || hwif->index != i)
+			{
+				idx[i] = 0xff;
 				continue;
+			}
 
 			memset(&hw, 0, sizeof(hw));
 			ide_std_init_ports(&hw, io_addr, io_addr + 0x206);
Signature · 1 line
1.5.4.2
#1 lore raw
Quoted 6 lines · Johann Felix Soden

From: Johann Felix Soden <[email protected]>

If the slot is already occupied, there should be written 0xff to idx[i]. In the ongoing code and in this case there are no writings to idx[i], so garbage stays in idx. The kernel get into a endless loop printing:

Quoted 8 lines

: I/O resource 0x0-0x0 not free.
Trying to free nonexistent resource <0000000000000000-0000000000000000> Trying to free nonexistent resource <0000000000000000-0000000000000000>

This patch solves http://article.gmane.org/gmane.linux.ide/28810 .

Thanks! I integrated it with the original patch to preserve bisectability:

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide-generic: use ide_find_port() (take 3)

There should be no functional changes caused by this patch.

v2:
* Fix comment (noticed by Sergei Shtylyov).

v3:
* Fix no initalization of idx in some case. (Johann Felix Soden)

Cc Johann Felix Soden <[email protected]>
Cc Kamalesh Babulal <[email protected]>
Cc Sergei Shtylyov <[email protected]>
---
 drivers/ide/ide-generic.c |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/ide/ide-generic.c +15 -4
Index: b/drivers/ide/ide-generic.c
===================================================================
@@ -90,18 +90,29 @@ static int __init ide_generic_init(void)
 	int i;
 
 	for (i = 0; i < MAX_HWIFS; i++) {
-		ide_hwif_t *hwif = &ide_hwifs[i];
+		ide_hwif_t *hwif;
 		unsigned long io_addr = ide_default_io_base(i);
 		hw_regs_t hw;
 
-		if (hwif->chipset == ide_unknown && io_addr) {
-			u8 oldnoprobe = hwif->noprobe;
+		if (io_addr) {
+			u8 oldnoprobe;
+
+			/*
+			 * Skip probing if the corresponding
+			 * slot is already occupied.
+			 */
+			hwif = ide_find_port();
+			if (hwif == NULL || hwif->index != i) {
+				idx[i] = 0xff;
+				continue;
+			}
 
 			memset(&hw, 0, sizeof(hw));
 			ide_std_init_ports(&hw, io_addr, io_addr + 0x206);
 			hw.irq = ide_default_irq(io_addr);
-			ide_init_port_hw(hwif, &hw);
 
+			oldnoprobe = hwif->noprobe;
+			ide_init_port_hw(hwif, &hw);
 			hwif->noprobe = oldnoprobe;
 
 			idx[i] = i;