Free memory allocated if any of the previous allocations failed. Signed-off-by: Xiaohui Zhang <xiaohuizh...@ruc.edu.cn> --- sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c b/sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c index 2292bb820..7f04042d2 100644 --- a/sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c +++ b/sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c @@ -542,8 +542,12 @@ static struct stream_encoder *dcn302_stream_encoder_create(enum engine_id eng_id vpg = dcn302_vpg_create(ctx, vpg_inst); afmt = dcn302_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); -- 2.17.1