drm/radeon: Fix potential null-ptr-deref
Commit Message
radeon_get_connector_for_encoder() assigns radeon_encoder->enc_priv to
mst_enc which is dereferenced later without being checked for NULL
beforehand. It is possible for radeon_encoder->enc_priv and therefore
mst_enc, to be NULL due to potential lack of memory.
This patch adds a sanity NULL-check to prevent the issue.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 9843ead08f18 ("drm/radeon: add DisplayPort MST support (v2)")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
---
drivers/gpu/drm/radeon/radeon_encoders.c | 3 +++
1 file changed, 3 insertions(+)
Comments
Due to my rookie mistake this patch isn't necessary anymore in
upstream version. The issue was already resolved in a different
manner.
Apologies for inconvenience.
@@ -251,6 +251,9 @@ radeon_get_connector_for_encoder(struct drm_encoder *encoder)
continue;
mst_enc = radeon_encoder->enc_priv;
+ if (!mst_enc)
+ return NULL;
+
if (mst_enc->connector == radeon_connector->mst_port)
return connector;
} else if (radeon_encoder->active_device & radeon_connector->devices)