Commit f5442b35 authored by Martin Leung's avatar Martin Leung Committed by Alex Deucher
Browse files

drm/amd/display: fix double memory allocation



[Why & How]
when trying to fix a nullptr dereference on VMs,
accidentally doubly allocated memory for the non VM
case. removed the extra link_srv creation since
dc_construct_ctx is called in both VM and non VM cases
Also added a proper fail check for if kzalloc fails

Cc: stable@vger.kernel.org
Cc: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: default avatarLeo Ma <Hanghong.Ma@amd.com>
Acked-by: default avatarQingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: default avatarMartin Leung <Martin.Leung@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent bf224e00
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -887,7 +887,10 @@ static bool dc_construct_ctx(struct dc *dc,
	}
	}


	dc->ctx = dc_ctx;
	dc->ctx = dc_ctx;

	dc->link_srv = link_create_link_service();
	dc->link_srv = link_create_link_service();
	if (!dc->link_srv)
		return false;


	return true;
	return true;
}
}
@@ -986,8 +989,6 @@ static bool dc_construct(struct dc *dc,
		goto fail;
		goto fail;
	}
	}


	dc->link_srv = link_create_link_service();

	dc->res_pool = dc_create_resource_pool(dc, init_params, dc_ctx->dce_version);
	dc->res_pool = dc_create_resource_pool(dc, init_params, dc_ctx->dce_version);
	if (!dc->res_pool)
	if (!dc->res_pool)
		goto fail;
		goto fail;