summaryrefslogtreecommitdiff
path: root/drivers/amba
diff options
context:
space:
mode:
authorWang Kefeng <wangkefeng.wang@huawei.com>2022-05-24 11:03:46 +0300
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2022-07-14 15:17:48 +0300
commit8030aa3ce12e3b9d47afa62344c601ed508c2d9e (patch)
tree259a370d56344ec99bb7407cd1f3365f473cee51 /drivers/amba
parente5c46fde75e43c15a29b40e5fc5641727f97ae47 (diff)
downloadlinux-8030aa3ce12e3b9d47afa62344c601ed508c2d9e.tar.xz
ARM: 9207/1: amba: fix refcount underflow if amba_device_add() fails
"ARM: 9192/1: amba: fix memory leak in amba_device_try_add()" leads to a refcount underflow if amba_device_add() fails, which called by of_amba_device_create(), the of_amba_device_create() already exists the error handling, so amba_put_device() only need to be added into amba_deferred_retry(). Fixes: 7719a68b2fa4 ("ARM: 9192/1: amba: fix memory leak in amba_device_try_add()") Reported-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'drivers/amba')
-rw-r--r--drivers/amba/bus.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 0e3ed5eb367b..0cb20324da16 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -493,13 +493,8 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
goto skip_probe;
ret = amba_read_periphid(dev);
- if (ret) {
- if (ret != -EPROBE_DEFER) {
- amba_device_put(dev);
- goto err_out;
- }
+ if (ret)
goto err_release;
- }
skip_probe:
ret = device_add(&dev->dev);
@@ -546,6 +541,7 @@ static int amba_deferred_retry(void)
continue;
list_del_init(&ddev->node);
+ amba_device_put(ddev->dev);
kfree(ddev);
}