From 150d74e7b8a3895b79e1cb7c95d258d833ee2ca3 Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 30 Nov 2023 02:57:53 +0000 Subject: [PATCH] drm/amd/display: fix a NULL pointer dereference in amdgpu_dm_i2c_xfer() From Mario Limonciello fb5c134ca589fe670430acc9e7ebf2691ca2476d in linux-6.1.y/6.1.64 b71f4ade1b8900d30c661d6c27f87c35214c398c in mainline linux --- sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 64a9b954d92..09815d3d365 100644 --- a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -7221,6 +7221,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) -- 2.20.1