diff mbox series

mips: cdmm: Fix refcount leak in mips_cdmm_phys_base

Message ID 20220309091711.3850-1-linmq006@gmail.com (mailing list archive)
State Accepted
Commit 4528668ca331f7ce5999b7746657b46db5b3b785
Headers show
Series mips: cdmm: Fix refcount leak in mips_cdmm_phys_base | expand

Commit Message

Miaoqian Lin March 9, 2022, 9:17 a.m. UTC
The of_find_compatible_node() function returns a node pointer with
refcount incremented, We should use of_node_put() on it when done
Add the missing of_node_put() to release the refcount.

Fixes: 2121aa3e2312 ("mips: cdmm: Add mti,mips-cdmm dtb node support")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/bus/mips_cdmm.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Serge Semin March 11, 2022, 2:29 p.m. UTC | #1
On Wed, Mar 09, 2022 at 09:17:10AM +0000, Miaoqian Lin wrote:
> The of_find_compatible_node() function returns a node pointer with
> refcount incremented, We should use of_node_put() on it when done
> Add the missing of_node_put() to release the refcount.
> 
> Fixes: 2121aa3e2312 ("mips: cdmm: Add mti,mips-cdmm dtb node support")

Nice catch. Thanks.

Acked-by: Serge Semin <fancer.lancer@gmail.com>

> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/bus/mips_cdmm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c
> index 626dedd110cb..fca0d0669aa9 100644
> --- a/drivers/bus/mips_cdmm.c
> +++ b/drivers/bus/mips_cdmm.c
> @@ -351,6 +351,7 @@ phys_addr_t __weak mips_cdmm_phys_base(void)
>  	np = of_find_compatible_node(NULL, NULL, "mti,mips-cdmm");
>  	if (np) {
>  		err = of_address_to_resource(np, 0, &res);
> +		of_node_put(np);
>  		if (!err)
>  			return res.start;
>  	}
> -- 
> 2.17.1
>
Thomas Bogendoerfer March 14, 2022, 2:52 p.m. UTC | #2
On Wed, Mar 09, 2022 at 09:17:10AM +0000, Miaoqian Lin wrote:
> The of_find_compatible_node() function returns a node pointer with
> refcount incremented, We should use of_node_put() on it when done
> Add the missing of_node_put() to release the refcount.
> 
> Fixes: 2121aa3e2312 ("mips: cdmm: Add mti,mips-cdmm dtb node support")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/bus/mips_cdmm.c | 1 +
>  1 file changed, 1 insertion(+)

applied to mips-next.

Thomas.
diff mbox series

Patch

diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c
index 626dedd110cb..fca0d0669aa9 100644
--- a/drivers/bus/mips_cdmm.c
+++ b/drivers/bus/mips_cdmm.c
@@ -351,6 +351,7 @@  phys_addr_t __weak mips_cdmm_phys_base(void)
 	np = of_find_compatible_node(NULL, NULL, "mti,mips-cdmm");
 	if (np) {
 		err = of_address_to_resource(np, 0, &res);
+		of_node_put(np);
 		if (!err)
 			return res.start;
 	}