2018-06-02 22:23:11

by Alexey Khoroshilov

[permalink] [raw]
Subject: [PATCH] power: reset: zx-reboot: put device node in zx_reboot_probe()

zx_reboot_probe() increments refcnt of zx296702-pcu device node by
of_find_compatible_node() and leaves it undecremented on both
successful and error paths.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <[email protected]>
---
drivers/power/reset/zx-reboot.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/power/reset/zx-reboot.c b/drivers/power/reset/zx-reboot.c
index c03e96e6a041..186901c96c01 100644
--- a/drivers/power/reset/zx-reboot.c
+++ b/drivers/power/reset/zx-reboot.c
@@ -51,6 +51,7 @@ static int zx_reboot_probe(struct platform_device *pdev)

np = of_find_compatible_node(NULL, NULL, "zte,zx296702-pcu");
pcu_base = of_iomap(np, 0);
+ of_node_put(np);
if (!pcu_base) {
iounmap(base);
WARN(1, "failed to map pcu_base address");
--
2.7.4



2018-06-03 09:06:04

by Nicholas Mc Guire

[permalink] [raw]
Subject: Re: [SIL2review] [PATCH] power: reset: zx-reboot: put device node in zx_reboot_probe()

On Sun, Jun 03, 2018 at 01:22:05AM +0300, Alexey Khoroshilov wrote:
> zx_reboot_probe() increments refcnt of zx296702-pcu device node by
> of_find_compatible_node() and leaves it undecremented on both
> successful and error paths.
>

Just wonder - if it warns on the failed case it probably should also
note if it failed in of_find_compatible_node() or not to allow
diagnosing the problem (the compatible_node score was 0) ?

> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <[email protected]>
Reviewed-by: Nicholas Mc Guire <[email protected]>

> ---
> drivers/power/reset/zx-reboot.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/power/reset/zx-reboot.c b/drivers/power/reset/zx-reboot.c
> index c03e96e6a041..186901c96c01 100644
> --- a/drivers/power/reset/zx-reboot.c
> +++ b/drivers/power/reset/zx-reboot.c
> @@ -51,6 +51,7 @@ static int zx_reboot_probe(struct platform_device *pdev)
>
> np = of_find_compatible_node(NULL, NULL, "zte,zx296702-pcu");
> pcu_base = of_iomap(np, 0);
> + of_node_put(np);
> if (!pcu_base) {
> iounmap(base);
> WARN(1, "failed to map pcu_base address");
> --
> 2.7.4
>
> _______________________________________________
> SIL2review mailing list
> [email protected]
> https://lists.osadl.org/mailman/listinfo/sil2review

2018-07-06 11:35:46

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH] power: reset: zx-reboot: put device node in zx_reboot_probe()

Hi,

On Sun, Jun 03, 2018 at 01:22:05AM +0300, Alexey Khoroshilov wrote:
> zx_reboot_probe() increments refcnt of zx296702-pcu device node by
> of_find_compatible_node() and leaves it undecremented on both
> successful and error paths.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <[email protected]>
> ---

Thanks, queued to power-supply-next.

-- Sebastian


Attachments:
(No filename) (440.00 B)
signature.asc (849.00 B)
Download all attachments