2022-08-23 07:12:46

by 赵军奎

[permalink] [raw]
Subject: [PATCH] drm/amd: fix potential memory leak

This patch fix potential memory leak (clk_src) when function run
into last return NULL.

Signed-off-by: Bernard Zhao <[email protected]>
---
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
index 85f32206a766..76f263846c6b 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
@@ -1715,6 +1715,7 @@ static struct clock_source *dcn30_clock_source_create(
}

BREAK_TO_DEBUGGER();
+ free(clk_src);
return NULL;
}

--
2.33.1


2022-08-25 16:13:33

by Alex Deucher

[permalink] [raw]
Subject: Re: [PATCH] drm/amd: fix potential memory leak

Applied. Thanks!

On Tue, Aug 23, 2022 at 3:29 AM Bernard Zhao <[email protected]> wrote:
>
> This patch fix potential memory leak (clk_src) when function run
> into last return NULL.
>
> Signed-off-by: Bernard Zhao <[email protected]>
> ---
> drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
> index 85f32206a766..76f263846c6b 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
> @@ -1715,6 +1715,7 @@ static struct clock_source *dcn30_clock_source_create(
> }
>
> BREAK_TO_DEBUGGER();
> + free(clk_src);
> return NULL;
> }
>
> --
> 2.33.1
>

2022-08-25 16:20:25

by Alex Deucher

[permalink] [raw]
Subject: Re: [PATCH] drm/amd: fix potential memory leak

On Tue, Aug 23, 2022 at 3:29 AM Bernard Zhao <[email protected]> wrote:
>
> This patch fix potential memory leak (clk_src) when function run
> into last return NULL.
>
> Signed-off-by: Bernard Zhao <[email protected]>
> ---
> drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
> index 85f32206a766..76f263846c6b 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
> @@ -1715,6 +1715,7 @@ static struct clock_source *dcn30_clock_source_create(
> }
>
> BREAK_TO_DEBUGGER();
> + free(clk_src);

This should be kfree(). Fixed up locally.

Alex

> return NULL;
> }
>
> --
> 2.33.1
>