Skip to contentSkip to conversation

via sata oops on init

DISCUSSION Dave Jones 2 participants 6 messages Jul 28, 2006 – Jul 29, 2006 SCSI

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

2.6.18-rc2-git6

BUG: unable to handle kernel NULL pointer dereference at 00000000
EIP is at make_class_name+0x27
eax: 00000000 ebx: ffffffff ecx: ffffffff edx: 00000009
esi: f8d16cc2 edi: 00000000 ebp: f7fa9d3c esp: f7fa9d2c

Call Trace:
class_device_del+0xac

class_device_unregister
scsi_remove_host
ata_host_remove
ata_device_add
svia_init_one
pci_device_probe
driver_probe_device
__driver_attach
bus_for_each_dev
driver_attach
bus_add_driver
driver_register
__pci_register_driver
svia_init
sys_init_module
syscall_call

Dave

Signature · 1 line
http://www.codemonkey.org.uk
#1 lore raw

Hi,

Quoted 9 lines · Dave Jones

2.6.18-rc2-git6

BUG: unable to handle kernel NULL pointer dereference at 00000000
EIP is at make_class_name+0x27
eax: 00000000 ebx: ffffffff ecx: ffffffff edx: 00000009
esi: f8d16cc2 edi: 00000000 ebp: f7fa9d3c esp: f7fa9d2c

Call Trace:
class_device_del+0xac
Quoted 4 lines

class_device_unregister
scsi_remove_host
ata_host_remove
ata_device_add

I think the problem lays in scsi/libata-core.c:5423 in torvalds/linux-2.6 v2.6.18-rc2-g6482132, stating:

[...]
struct ata_host_set *host_set = kzalloc(...);
[...]

Initialization of some structure members, but not ports(!)

for (...) {
	struct ata_port *ap;

	ap = ata_host_add(ent, host_set, i);
	if (!ap)
		goto err_out;
	
	host_set->ports[i] = ap;

err_out:

	for (i = 0; i < count; i++) {
		ata_host_remove(host_set->ports[i], 1);

[...]

ata_device_add fails, calls ata_host_remove with pointers to unitialized memory.

Hannes

author
#2 lore raw
Quoted 3 lines · Johannes Weiner

..
ata_device_add fails, calls ata_host_remove with pointers to unitialized memory.

This should do it. Jeff?

Fix reference of uninitialised memory in ata_device_add()

drivers/scsi/libata-core.c renamed from drivers/scsi/libata-core.c~ +3 -1
@@ -5419,10 +5419,10 @@ int ata_device_add(const struct ata_prob
 		unsigned long xfer_mode_mask;
 
 		ap = ata_host_add(ent, host_set, i);
+		host_set->ports[i] = ap;
 		if (!ap)
 			goto err_out;
 
-		host_set->ports[i] = ap;
 		xfer_mode_mask =(ap->udma_mask << ATA_SHIFT_UDMA) |
 				(ap->mwdma_mask << ATA_SHIFT_MWDMA) |
 				(ap->pio_mask << ATA_SHIFT_PIO);
@@ -5532,6 +5532,8 @@ int ata_device_add(const struct ata_prob
 
 err_out:
 	for (i = 0; i < count; i++) {
+		if (!host_set->ports[i])
+			break;
 		ata_host_remove(host_set->ports[i], 1);
 		scsi_host_put(host_set->ports[i]->host);
 	}
Signature · 1 line
http://www.codemonkey.org.uk
#3 lore raw

Hi,

Quoted 15 lines · Dave Jones
drivers/scsi/libata-core.c renamed from drivers/scsi/libata-core.c~ +1 -1
@@ -5419,10 +5419,10 @@ int ata_device_add(const struct ata_prob
 		unsigned long xfer_mode_mask;
 
 		ap = ata_host_add(ent, host_set, i);
+		host_set->ports[i] = ap;
 		if (!ap)
 			goto err_out;
 
-		host_set->ports[i] = ap;
 		xfer_mode_mask =(ap->udma_mask << ATA_SHIFT_UDMA) |
 				(ap->mwdma_mask << ATA_SHIFT_MWDMA) |
 				(ap->pio_mask << ATA_SHIFT_PIO);

drivers/scsi/libata-core.c int ata_device_add(const struct ata_prob · line 5539

Quoted 8 lines
drivers/scsi/libata-core.c renamed from drivers/scsi/libata-core.c~ +2 -0
@@ -5532,6 +5532,8 @@ int ata_device_add(const struct ata_prob
 
 err_out:
 	for (i = 0; i < count; i++) {
+		if (!host_set->ports[i])
+			break;
 		ata_host_remove(host_set->ports[i], 1);
 		scsi_host_put(host_set->ports[i]->host);
 	}

You jump into loop just to skip it.

drivers/scsi/libata-core.c +1 -1
index 386e5f2..064ee85 100644
@@ -5420,7 +5420,7 @@ int ata_device_add(const struct ata_prob
 
 		ap = ata_host_add(ent, host_set, i);
 		if (!ap)
-			goto err_out;
+			goto err_free_ret;
 
 		host_set->ports[i] = ap;
 		xfer_mode_mask =(ap->udma_mask << ATA_SHIFT_UDMA) |
author
#4 lore raw
Quoted 1 line · Johannes Weiner

You jump into loop just to skip it.

You have to. Look at the allocation again. It's in a loop. The first of which may have succeeded. Your patch will introduce a memory leak.

Dave

Quoted 13 lines
drivers/scsi/libata-core.c +1 -1
index 386e5f2..064ee85 100644
@@ -5420,7 +5420,7 @@ int ata_device_add(const struct ata_prob
 
 		ap = ata_host_add(ent, host_set, i);
 		if (!ap)
-			goto err_out;
+			goto err_free_ret;
 
 		host_set->ports[i] = ap;
 		xfer_mode_mask =(ap->udma_mask << ATA_SHIFT_UDMA) |
Signature · 1 line
http://www.codemonkey.org.uk
#5 lore raw

Hi,

Quoted 3 lines · Dave Jones

You have to. Look at the allocation again. It's in a loop. The first of which may have succeeded. Your patch will introduce a memory leak.

Holy crap! Yeah, I see it. Thanks :)

Hannes