Skip to content

Commit

Permalink
libata: clear drvdata in ata_host_release(), take#2
Browse files Browse the repository at this point in the history
Clearing drvdata in ->remove_one causes NULL pointer deference.  Clear
drvdata only in ata_host_release() after all resources are freed.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Mar 2, 2007
1 parent 7b965e0 commit 1aa56cc
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 4 deletions.
3 changes: 2 additions & 1 deletion drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5680,6 +5680,8 @@ static void ata_host_release(struct device *gendev, void *res)

if (host->ops->host_stop)
host->ops->host_stop(host);

dev_set_drvdata(gendev, NULL);
}

/**
Expand Down Expand Up @@ -5902,7 +5904,6 @@ int ata_device_add(const struct ata_probe_ent *ent)

err_out:
devres_release_group(dev, ata_device_add);
dev_set_drvdata(dev, NULL);
VPRINTK("EXIT, returning %d\n", rc);
return 0;
}
Expand Down
1 change: 0 additions & 1 deletion drivers/ata/pata_cs5520.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ static void __devexit cs5520_remove_one(struct pci_dev *pdev)
struct ata_host *host = dev_get_drvdata(dev);

ata_host_detach(host);
dev_set_drvdata(dev, NULL);
}

/**
Expand Down
1 change: 0 additions & 1 deletion drivers/ata/pata_isapnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ static void isapnp_remove_one(struct pnp_dev *idev)
struct ata_host *host = dev_get_drvdata(dev);

ata_host_detach(host);
dev_set_drvdata(dev, NULL);
}

static struct pnp_device_id isapnp_devices[] = {
Expand Down
1 change: 0 additions & 1 deletion drivers/ata/pata_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ static int __devexit pata_platform_remove(struct platform_device *pdev)
struct ata_host *host = dev_get_drvdata(dev);

ata_host_detach(host);
dev_set_drvdata(dev, NULL);

return 0;
}
Expand Down

0 comments on commit 1aa56cc

Please sign in to comment.