drm/amd/display: fix a NULL pointer dereference in amdgpu_dm_i2c_xfer()
authorjsg <jsg@openbsd.org>
Thu, 30 Nov 2023 02:57:53 +0000 (02:57 +0000)
committerjsg <jsg@openbsd.org>
Thu, 30 Nov 2023 02:57:53 +0000 (02:57 +0000)
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

index 64a9b95..09815d3 100644 (file)
@@ -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)