diff options
author | Tejun Heo <htejun@gmail.com> | 2006-08-04 14:59:19 -0400 |
---|---|---|
committer | Tejun Heo <htejun@gmail.com> | 2006-08-04 14:59:19 -0400 |
commit | 77f3f879387cc5fce6c7a4ca7777c586fe6291cd (patch) | |
tree | 86cdb66936984d02bd1da3a84deec72fd805400d | |
parent | 6543bc0777fadf129d8ee7ac82e0090fb0480403 (diff) |
[PATCH] libata: fix ata_device_add() error path
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@redhat.com>. The second problem
was mentioned and fixed by Jeff Garzik <jgarzik@pobox.com> in a larger
cleanup patch.
Cc: Dave Jones <davej@redhat.com>
Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Tejun Heo <htejun@gmail.com>
-rw-r--r-- | drivers/scsi/libata-core.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 509b04889983..16fc2dd8f2f7 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -5511,10 +5511,10 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
5511 | err_out: | 5511 | err_out: |
5512 | for (i = 0; i < count; i++) { | 5512 | for (i = 0; i < count; i++) { |
5513 | struct ata_port *ap = host_set->ports[i]; | 5513 | struct ata_port *ap = host_set->ports[i]; |
5514 | 5514 | if (ap) { | |
5515 | scsi_remove_host(ap->host); | 5515 | ap->ops->port_stop(ap); |
5516 | ap->ops->port_stop(ap); | 5516 | scsi_host_put(ap->host); |
5517 | scsi_host_put(ap->host); | 5517 | } |
5518 | } | 5518 | } |
5519 | err_free_ret: | 5519 | err_free_ret: |
5520 | kfree(host_set); | 5520 | kfree(host_set); |