Skip to content

Commit 03388a3

Browse files
Anson Jacobalexdeucher
authored andcommitted
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 <[email protected]> Acked-by: Mikita Lipski <[email protected]> Signed-off-by: Anson Jacob <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent f5d8e16 commit 03388a3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,12 @@ static struct stream_encoder *dcn303_stream_encoder_create(enum engine_id eng_id
510510
vpg = dcn303_vpg_create(ctx, vpg_inst);
511511
afmt = dcn303_afmt_create(ctx, afmt_inst);
512512

513-
if (!enc1 || !vpg || !afmt)
513+
if (!enc1 || !vpg || !afmt) {
514+
kfree(enc1);
515+
kfree(vpg);
516+
kfree(afmt);
514517
return NULL;
518+
}
515519

516520
dcn30_dio_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id, vpg, afmt, &stream_enc_regs[eng_id],
517521
&se_shift, &se_mask);

0 commit comments

Comments
 (0)