Re: [RESEND PATCH] drm/amd/display: prevent memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 10/26/22 06:01, gehao618@xxxxxxx wrote:
From: gehao <gehao@xxxxxxxxxx>

In dce6(0,1,4)_create_resource_pool and dce8(0,1)_create_resource_pool
the allocated memory should be released if construct pool fails.

Signed-off-by: gehao <gehao@xxxxxxxxxx>
---
  drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c | 3 +++
  drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c | 2 ++
  2 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c b/drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c
index fc6aa098bda0..8db9f7514466 100644
--- a/drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c
@@ -1128,6 +1128,7 @@ struct resource_pool *dce60_create_resource_pool(
  	if (dce60_construct(num_virtual_links, dc, pool))
  		return &pool->base;
+ kfree(pool);
  	BREAK_TO_DEBUGGER();
  	return NULL;
  }
@@ -1325,6 +1326,7 @@ struct resource_pool *dce61_create_resource_pool(
  	if (dce61_construct(num_virtual_links, dc, pool))
  		return &pool->base;
+ kfree(pool);
  	BREAK_TO_DEBUGGER();
  	return NULL;
  }
@@ -1518,6 +1520,7 @@ struct resource_pool *dce64_create_resource_pool(
  	if (dce64_construct(num_virtual_links, dc, pool))
  		return &pool->base;
+ kfree(pool);
  	BREAK_TO_DEBUGGER();
  	return NULL;
  }
diff --git a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c
index b28025960050..5825e6f412bd 100644
--- a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c
@@ -1137,6 +1137,7 @@ struct resource_pool *dce80_create_resource_pool(
  	if (dce80_construct(num_virtual_links, dc, pool))
  		return &pool->base;
+ kfree(pool);
  	BREAK_TO_DEBUGGER();
  	return NULL;
  }
@@ -1336,6 +1337,7 @@ struct resource_pool *dce81_create_resource_pool(
  	if (dce81_construct(num_virtual_links, dc, pool))
  		return &pool->base;
+ kfree(pool);
  	BREAK_TO_DEBUGGER();
  	return NULL;
  }

LGTM,

Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@xxxxxxx>

Applied to amd-staging-drm-next.

Thanks
Siqueira



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux