Skip to content

Commit 8030aa3

Browse files
Wang KefengRussell King (Oracle)
authored andcommitted
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: 7719a68 ("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>
1 parent e5c46fd commit 8030aa3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/amba/bus.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,8 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
493493
goto skip_probe;
494494

495495
ret = amba_read_periphid(dev);
496-
if (ret) {
497-
if (ret != -EPROBE_DEFER) {
498-
amba_device_put(dev);
499-
goto err_out;
500-
}
496+
if (ret)
501497
goto err_release;
502-
}
503498

504499
skip_probe:
505500
ret = device_add(&dev->dev);
@@ -546,6 +541,7 @@ static int amba_deferred_retry(void)
546541
continue;
547542

548543
list_del_init(&ddev->node);
544+
amba_device_put(ddev->dev);
549545
kfree(ddev);
550546
}
551547

0 commit comments

Comments
 (0)