linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] video: fbdev: Fix refcount leak in clcdfb_of_vram_setup
@ 2022-05-12 11:59 Miaoqian Lin
  2022-05-19  9:14 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2022-05-12 11:59 UTC (permalink / raw)
  To: Russell King, Helge Deller, Miaoqian Lin, Pawel Moll,
	Tomi Valkeinen, linux-fbdev, dri-devel, linux-kernel

of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: d10715be03bd ("video: ARM CLCD: Add DT support")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/video/fbdev/amba-clcd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
index 9ec969e136bf..8080116aea84 100644
--- a/drivers/video/fbdev/amba-clcd.c
+++ b/drivers/video/fbdev/amba-clcd.c
@@ -758,12 +758,15 @@ static int clcdfb_of_vram_setup(struct clcd_fb *fb)
 		return -ENODEV;
 
 	fb->fb.screen_base = of_iomap(memory, 0);
-	if (!fb->fb.screen_base)
+	if (!fb->fb.screen_base) {
+		of_node_put(memory);
 		return -ENOMEM;
+	}
 
 	fb->fb.fix.smem_start = of_translate_address(memory,
 			of_get_address(memory, 0, &size, NULL));
 	fb->fb.fix.smem_len = size;
+	of_node_put(memory);
 
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] video: fbdev: Fix refcount leak in clcdfb_of_vram_setup
  2022-05-12 11:59 [PATCH] video: fbdev: Fix refcount leak in clcdfb_of_vram_setup Miaoqian Lin
@ 2022-05-19  9:14 ` Helge Deller
  0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2022-05-19  9:14 UTC (permalink / raw)
  To: Miaoqian Lin, Russell King, Pawel Moll, Tomi Valkeinen,
	linux-fbdev, dri-devel, linux-kernel

On 5/12/22 13:59, Miaoqian Lin wrote:
> of_parse_phandle() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() to avoid refcount leak.
>
> Fixes: d10715be03bd ("video: ARM CLCD: Add DT support")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

applied to the fbdev tree.
Thanks!
Helge

> ---
>  drivers/video/fbdev/amba-clcd.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
> index 9ec969e136bf..8080116aea84 100644
> --- a/drivers/video/fbdev/amba-clcd.c
> +++ b/drivers/video/fbdev/amba-clcd.c
> @@ -758,12 +758,15 @@ static int clcdfb_of_vram_setup(struct clcd_fb *fb)
>  		return -ENODEV;
>
>  	fb->fb.screen_base = of_iomap(memory, 0);
> -	if (!fb->fb.screen_base)
> +	if (!fb->fb.screen_base) {
> +		of_node_put(memory);
>  		return -ENOMEM;
> +	}
>
>  	fb->fb.fix.smem_start = of_translate_address(memory,
>  			of_get_address(memory, 0, &size, NULL));
>  	fb->fb.fix.smem_len = size;
> +	of_node_put(memory);
>
>  	return 0;
>  }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-19  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-12 11:59 [PATCH] video: fbdev: Fix refcount leak in clcdfb_of_vram_setup Miaoqian Lin
2022-05-19  9:14 ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).