Skip to contentSkip to conversation

drm/amd/display: invalid parameter check in dmub_hpd_callback

PATCH Applied José Expósito 3 participants 3 messages Jan 9, 2022 – Jan 10, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: invalid parameter check in dmub_hpd_callback

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 e27c41d5b0681 ("drm/amd/display: Support for DMUB HPD interrupt handling")

Addresses-Coverity-ID: 1493909 ("Null pointer dereference")

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
index e727f1dd2a9a..7fbded7a6d9c 100644
@@ -656,7 +656,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
 	struct drm_connector_list_iter iter;
 	struct dc_link *link;
 	uint8_t link_index = 0;
-	struct drm_device *dev = adev->dm.ddev;
+	struct drm_device *dev;
 
 	if (adev == NULL)
 		return;
@@ -673,6 +673,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
 
 	link_index = notify->link_index;
 	link = adev->dm.dc->links[link_index];
+	dev = adev->dm.ddev;
 
 	drm_connector_list_iter_begin(dev, &iter);
 	drm_for_each_connector_iter(connector, &iter) {
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · José Expósito

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 e27c41d5b0681 ("drm/amd/display: Support for DMUB HPD interrupt handling")

Addresses-Coverity-ID: 1493909 ("Null pointer dereference")

Harry

Quoted 25 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
index e727f1dd2a9a..7fbded7a6d9c 100644
@@ -656,7 +656,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
 	struct drm_connector_list_iter iter;
 	struct dc_link *link;
 	uint8_t link_index = 0;
-	struct drm_device *dev = adev->dm.ddev;
+	struct drm_device *dev;
 
 	if (adev == NULL)
 		return;
@@ -673,6 +673,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
 
 	link_index = notify->link_index;
 	link = adev->dm.dc->links[link_index];
+	dev = adev->dm.ddev;
 
 	drm_connector_list_iter_begin(dev, &iter);
 	drm_for_each_connector_iter(connector, &iter) {
Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 42 lines · Harry Wentland
Quoted 9 lines · José Expósito

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 e27c41d5b0681 ("drm/amd/display: Support for DMUB HPD interrupt handling")

Addresses-Coverity-ID: 1493909 ("Null pointer dereference")

Harry

Quoted 25 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
index e727f1dd2a9a..7fbded7a6d9c 100644
@@ -656,7 +656,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
      struct drm_connector_list_iter iter;
      struct dc_link *link;
      uint8_t link_index = 0;
-     struct drm_device *dev = adev->dm.ddev;
+     struct drm_device *dev;
 
      if (adev == NULL)
              return;
@@ -673,6 +673,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not
 
      link_index = notify->link_index;
      link = adev->dm.dc->links[link_index];
+     dev = adev->dm.ddev;
 
      drm_connector_list_iter_begin(dev, &iter);
      drm_for_each_connector_iter(connector, &iter) {