drm/amd/display: invalid parameter check in dmub_hpd_callback

commit 978ffac878 upstream.

The function performs a check on the "adev" input parameter, however, it
is used before the check.

Initialize the "dev" variable after the sanity check to avoid a possible
NULL pointer dereference.

Fixes: e27c41d5b0 ("drm/amd/display: Support for DMUB HPD interrupt handling")
Addresses-Coverity-ID: 1493909 ("Null pointer dereference")
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
José Expósito 2022-01-09 19:42:45 +01:00 коммит произвёл Greg Kroah-Hartman
Родитель 760fe32034
Коммит f85a6046f7
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -653,7 +653,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
struct drm_connector_list_iter iter; struct drm_connector_list_iter iter;
struct dc_link *link; struct dc_link *link;
uint8_t link_index = 0; uint8_t link_index = 0;
struct drm_device *dev = adev->dm.ddev; struct drm_device *dev;
if (adev == NULL) if (adev == NULL)
return; return;
@ -670,6 +670,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
link_index = notify->link_index; link_index = notify->link_index;
link = adev->dm.dc->links[link_index]; link = adev->dm.dc->links[link_index];
dev = adev->dm.ddev;
drm_connector_list_iter_begin(dev, &iter); drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) { drm_for_each_connector_iter(connector, &iter) {