[PATCH 05/11] libata: fix ata_device_add() error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the error path, ata_device_add()

* dereferences null host_set->ports[] element.
* calls scsi_remove_host() on not-yet-added shost.

This patch fixes both bugs.  The first problem was spotted and initial
patch submitted by Dave Jones <davej@xxxxxxxxxx>.  The second problem
was mentioned and fixed by Jeff Garzik <jgarzik@xxxxxxxxx> in a larger
cleanup patch.

Signed-off-by: Tejun Heo <htejun@xxxxxxxxx>
Cc: Dave Jones <davej@xxxxxxxxxx>
Cc: Jeff Garzik <jgarzik@xxxxxxxxx>

---

 drivers/scsi/libata-core.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

4d1a48cb2671959685bdeef6d186727b9cfeee10
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index fdcc58e..96fc7a5 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -5505,10 +5505,10 @@ int ata_device_add(const struct ata_prob
 err_out:
 	for (i = 0; i < host_set->n_ports; i++) {
 		struct ata_port *ap = host_set->ports[i];
-
-		scsi_remove_host(ap->host);
-		ap->ops->port_stop(ap);
-		scsi_host_put(ap->host);
+		if (ap) {
+			ap->ops->port_stop(ap);
+			scsi_host_put(ap->host);
+		}
 	}
 
 	kfree(host_set);
-- 
1.3.2


-
: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux