Skip to content

Commit

Permalink
[PATCH] libata: fix ata_device_add() error path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tejun Heo committed Aug 4, 2006
1 parent 6543bc0 commit 77f3f87
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/scsi/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5511,10 +5511,10 @@ int ata_device_add(const struct ata_probe_ent *ent)
err_out:
for (i = 0; i < count; 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);
}
}
err_free_ret:
kfree(host_set);
Expand Down

0 comments on commit 77f3f87

Please sign in to comment.