Skip to contentSkip to conversation

drm/amd: fix potential memory leak

PATCH Applied Bernard Zhao 2 participants 3 messages Aug 23, 2022 – Aug 25, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: fix potential memory leak

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

---
 drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c +1 -0
index 85f32206a766..76f263846c6b 100644
@@ -1715,6 +1715,7 @@ static struct clock_source *dcn30_clock_source_create(
 	}
 
 	BREAK_TO_DEBUGGER();
+	free(clk_src);
 	return NULL;
 }
 
Signature · 1 line
2.33.1
Applied
#1 lore raw

Applied. Thanks!

Quoted 24 lines · Bernard Zhao

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

---
 drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c +1 -1
index 85f32206a766..76f263846c6b 100644
@@ -1715,6 +1715,7 @@ static struct clock_source *dcn30_clock_source_create(
        }
 
        BREAK_TO_DEBUGGER();
+       free(clk_src);
        return NULL;
 }
 
--

2.33.1

#2 lore raw
In reply to Bernard Zhao
Quoted 14 lines · Bernard Zhao

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

---
 drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c +0 -0
index 85f32206a766..76f263846c6b 100644

drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c static struct clock_source *dcn30_clock_source_create( · line 1718

Quoted 4 lines
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c +1 -0
@@ -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

Quoted 6 lines
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c +0 -1
        return NULL;
 }
 
--

2.33.1