diff options
author | Colin Ian King <colin.king@canonical.com> | 2018-03-27 15:26:01 +0200 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2018-03-27 15:56:02 +0200 |
commit | dafd6c496381c1cd1f5ba9ad953e810bdcc931bc (patch) | |
tree | 639daf250f821153d2e2c6d65240ea9bb68b838c | |
parent | ata: ahci-platform: add reset control support (diff) | |
download | linux-dafd6c496381c1cd1f5ba9ad953e810bdcc931bc.tar.xz linux-dafd6c496381c1cd1f5ba9ad953e810bdcc931bc.zip |
libata: ensure host is free'd on error exit paths
The host structure is not being kfree'd on two error exit paths
leading to memory leaks. Add in new err_free label and kfree host.
Detected by CoverityScan, CID#1466103 ("Resource leak")
Fixes: 2623c7a5f279 ("libata: add refcounting to ata_host")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | drivers/ata/libata-core.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index b8b85bf97288..191a55e760a0 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6087,7 +6087,7 @@ struct ata_host *ata_host_alloc(struct device *dev, int max_ports) return NULL; if (!devres_open_group(dev, NULL, GFP_KERNEL)) - return NULL; + goto err_free; dr = devres_alloc(ata_devres_release, 0, GFP_KERNEL); if (!dr) @@ -6119,6 +6119,8 @@ struct ata_host *ata_host_alloc(struct device *dev, int max_ports) err_out: devres_release_group(dev, NULL); + err_free: + kfree(host); return NULL; } |