diff mbox series

drm/radeon: Fix potential null-ptr-deref

Message ID 20221226181023.86196-1-n.zhandarovich@fintech.ru (mailing list archive)
State New, archived
Headers show
Series drm/radeon: Fix potential null-ptr-deref | expand

Commit Message

Nikita Zhandarovich Dec. 26, 2022, 6:10 p.m. UTC
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(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 46549d5179ee..3f68f0af443a 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -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)