From: Nicholas Kazlauskas Date: Fri, 18 Dec 2020 17:14:00 +0000 (-0500) Subject: drm/amd/display: Guard against NULL pointer deref when get_i2c_info fails X-Git-Tag: v5.12-rc1~132^2~5^2~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=44a09e3d95bd2b7b0c224100f78f335859c4e193;p=thirdparty%2Flinux.git drm/amd/display: Guard against NULL pointer deref when get_i2c_info fails [Why] If the BIOS table is invalid or corrupt then get_i2c_info can fail and we dereference a NULL pointer. [How] Check that ddc_pin is not NULL before using it and log an error if it is because this is unexpected. Tested-by: Daniel Wheeler Signed-off-by: Nicholas Kazlauskas Reviewed-by: Eric Yang Acked-by: Anson Jacob Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 5ecb402537ade..30edbf19e9a15 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -1481,6 +1481,11 @@ static bool dc_link_construct(struct dc_link *link, goto ddc_create_fail; } + if (!link->ddc->ddc_pin) { + DC_ERROR("Failed to get I2C info for connector!\n"); + goto ddc_create_fail; + } + link->ddc_hw_inst = dal_ddc_get_line(dal_ddc_service_get_ddc_pin(link->ddc));