Commit 9f3a9e2a authored by Mario Limonciello's avatar Mario Limonciello Committed by Zheng Zengkai
Browse files

drm/amd/display: fix a NULL pointer dereference in amdgpu_dm_i2c_xfer()

stable inclusion
from stable-v6.6.3
commit 1d07b7e84276777dad3c8cfebdf8e739606f90c9
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8LBQP

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1d07b7e84276777dad3c8cfebdf8e739606f90c9

--------------------------------

commit b71f4ade1b8900d30c661d6c27f87c35214c398c upstream.

When ddc_service_construct() is called, it explicitly checks both the
link type and whether there is something on the link which will
dictate whether the pin is marked as hw_supported.

If the pin isn't set or the link is not set (such as from
unloading/reloading amdgpu in an IGT test) then fail the
amdgpu_dm_i2c_xfer() call.

Cc: stable@vger.kernel.org
Fixes: 22676bc5 ("drm/amd/display: Fix dmub soft hang for PSR 1")
Link: https://github.com/fwupd/fwupd/issues/6327


Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 1366bdf1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7430,6 +7430,9 @@ static int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap,
	int i;
	int result = -EIO;

	if (!ddc_service->ddc_pin || !ddc_service->ddc_pin->hw_info.hw_supported)
		return result;

	cmd.payloads = kcalloc(num, sizeof(struct i2c_payload), GFP_KERNEL);

	if (!cmd.payloads)