summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
diff options
context:
space:
mode:
authorAnson Jacob <Anson.Jacob@amd.com>2021-08-14 00:11:51 +0300
committerAlex Deucher <alexander.deucher@amd.com>2021-08-31 21:19:00 +0300
commit03388a347fe7cf7c3bdf68b0823ba316d177d470 (patch)
tree1d10c3a28fbae14552d062a189cc88f719a93f3c /drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
parentf5d8e16488056d9ad48d2561ef4eaf7fdd11c162 (diff)
downloadlinux-03388a347fe7cf7c3bdf68b0823ba316d177d470.tar.xz
drm/amd/display: Fix memory leak reported by coverity
Free memory allocated if any of the previous allocations failed. >>> CID 1487129: Resource leaks (RESOURCE_LEAK) >>> Variable "vpg" going out of scope leaks the storage it points to. Addresses-Coverity-ID: 1487129: ("Resource leaks") Reviewed-by: Aric Cyr <aric.cyr@amd.com> Acked-by: Mikita Lipski <mikita.lipski@amd.com> Signed-off-by: Anson Jacob <Anson.Jacob@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c')
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c b/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
index dc7823d23ba8..dd38796ba30a 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
@@ -510,8 +510,12 @@ static struct stream_encoder *dcn303_stream_encoder_create(enum engine_id eng_id
vpg = dcn303_vpg_create(ctx, vpg_inst);
afmt = dcn303_afmt_create(ctx, afmt_inst);
- if (!enc1 || !vpg || !afmt)
+ if (!enc1 || !vpg || !afmt) {
+ kfree(enc1);
+ kfree(vpg);
+ kfree(afmt);
return NULL;
+ }
dcn30_dio_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id, vpg, afmt, &stream_enc_regs[eng_id],
&se_shift, &se_mask);