[bug report] drm/amd/display: fix null-pointer dereference on edid reading

Dan Carpenter dan.carpenter at linaro.org
Mon Feb 26 14:42:20 UTC 2024


Hello Melissa Wen,

This is a semi-automatic email about new static checker warnings.

    drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:6683 amdgpu_dm_connector_funcs_force()
    warn: variable dereferenced before check 'dc_link' (see line 6663)

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c
  6662	
  6663		if (dc_link->aux_mode)
                    ^^^^^^^^^
The patch adds an unchecked dereference

  6664			ddc = &aconnector->dm_dp_aux.aux.ddc;
  6665		else
  6666			ddc = &aconnector->i2c->base;
  6667	
  6668		/*
  6669		 * Note: drm_get_edid gets edid in the following order:
  6670		 * 1) override EDID if set via edid_override debugfs,
  6671		 * 2) firmware EDID if set via edid_firmware module parameter
  6672		 * 3) regular DDC read.
  6673		 */
  6674		edid = drm_get_edid(connector, ddc);
  6675		if (!edid) {
  6676			DRM_ERROR("No EDID found on connector: %s.\n", connector->name);
  6677			return;
  6678		}
  6679	
  6680		aconnector->edid = edid;
  6681	
  6682		/* Update emulated (virtual) sink's EDID */
  6683		if (dc_em_sink && dc_link) {
                                  ^^^^^^^
The existing code assumed dc_link could be NULL?  Can it?  If not then
let's delete this check.

  6684			memset(&dc_em_sink->edid_caps, 0, sizeof(struct dc_edid_caps));
  6685			memmove(dc_em_sink->dc_edid.raw_edid, edid, (edid->extensions + 1) * EDID_LENGTH);

regards,
dan carpenter


More information about the amd-gfx mailing list