diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2820-drm-amd-display-fix-memory-leaks-on-error-exit-retur.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2820-drm-amd-display-fix-memory-leaks-on-error-exit-retur.patch | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2820-drm-amd-display-fix-memory-leaks-on-error-exit-retur.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2820-drm-amd-display-fix-memory-leaks-on-error-exit-retur.patch new file mode 100644 index 00000000..2443d9dd --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2820-drm-amd-display-fix-memory-leaks-on-error-exit-retur.patch @@ -0,0 +1,48 @@ +From a2b2e5de37f1e1d7cb0b268a6944f30583704c5e Mon Sep 17 00:00:00 2001 +From: Colin Ian King <colin.king@canonical.com> +Date: Wed, 22 Nov 2017 16:47:35 +0000 +Subject: [PATCH 2820/4131] drm/amd/display: fix memory leaks on error exit + return + +Currently in the case where some of the allocations fail for dce110_tgv, +dce110_xfmv, dce110_miv or dce110_oppv then the exit return path ends +up leaking allocated objects. Fix this by kfree'ing them before returning. +Also re-work the comparison of the null pointers to use the !ptr idiom. + +Detected by CoverityScan, CID#1460246, 1460325, 1460324, 1460392 +("Resource Leak") + +Fixes: c4562236b3bc ("drm/amd/dc: Add dc display driver (v2)") +Signed-off-by: Colin Ian King <colin.king@canonical.com> +Reviewed-by: Harry Wentland <harry.wentland@amd.com> +Signed-off-by: Alex Deucher <alexander.deucher@amd.com> +--- + drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +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 5b30e12..5228ee7 100644 +--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c ++++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +@@ -1037,11 +1037,13 @@ static bool underlay_create(struct dc_context *ctx, struct resource_pool *pool) + struct dce110_opp *dce110_oppv = kzalloc(sizeof(*dce110_oppv), + GFP_KERNEL); + +- if ((dce110_tgv == NULL) || +- (dce110_xfmv == NULL) || +- (dce110_miv == NULL) || +- (dce110_oppv == NULL)) +- return false; ++ if (!dce110_tgv || !dce110_xfmv || !dce110_miv || !dce110_oppv) { ++ kfree(dce110_tgv); ++ kfree(dce110_xfmv); ++ kfree(dce110_miv); ++ kfree(dce110_oppv); ++ return false; ++ } + + dce110_opp_v_construct(dce110_oppv, ctx); + +-- +2.7.4 + |