| From 2e5f50144b3e4d25d42bbfe30658e3c457fd02e5 Mon Sep 17 00:00:00 2001 |
| From: Navid Emamdoost <navid.emamdoost@gmail.com> |
| Date: Tue, 24 Sep 2019 23:23:56 -0500 |
| Subject: [PATCH] drm/amd/display: prevent memory leak |
| |
| commit 104c307147ad379617472dd91a5bcb368d72bd6d upstream. |
| |
| In dcn*_create_resource_pool the allocated memory should be released if |
| construct pool fails. |
| |
| Reviewed-by: Harry Wentland <harry.wentland@amd.com> |
| Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com> |
| Signed-off-by: Alex Deucher <alexander.deucher@amd.com> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c |
| index b3d80cb5c774..c17aa0c274c2 100644 |
| --- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c |
| +++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c |
| @@ -1077,6 +1077,7 @@ struct resource_pool *dce100_create_resource_pool( |
| if (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/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c |
| index 7b83aaad3211..726d6bce6f70 100644 |
| --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c |
| +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c |
| @@ -1452,6 +1452,7 @@ struct resource_pool *dce110_create_resource_pool( |
| if (construct(num_virtual_links, dc, pool, asic_id)) |
| return &pool->base; |
| |
| + kfree(pool); |
| BREAK_TO_DEBUGGER(); |
| return NULL; |
| } |
| diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c |
| index d683dab00cd7..b0df5acb716e 100644 |
| --- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c |
| +++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c |
| @@ -1364,6 +1364,7 @@ struct resource_pool *dce112_create_resource_pool( |
| if (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/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c |
| index ed2535a72da1..7557dd7ce4df 100644 |
| --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c |
| +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c |
| @@ -1227,6 +1227,7 @@ struct resource_pool *dce120_create_resource_pool( |
| if (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/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c |
| index e333005a3788..17a119d43671 100644 |
| --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c |
| +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c |
| @@ -1557,6 +1557,7 @@ struct resource_pool *dcn10_create_resource_pool( |
| if (construct(init_data->num_virtual_links, dc, pool)) |
| return &pool->base; |
| |
| + kfree(pool); |
| BREAK_TO_DEBUGGER(); |
| return NULL; |
| } |
| -- |
| 2.7.4 |
| |