[PATCH] drm/radeon: avoid a possible array overflow

Yang Xiao YangX92 at hotmail.com
Mon Dec 17 11:52:49 UTC 2018


From: Young Xiao <YangX92 at hotmail.com>

When looking up the connector type make sure the index
is valid.  Avoids a later crash if we read past the end
of the array.

See commit e1718d97aa88 ("drm/amdgpu: avoid a possible
array overflow") for detail.

Signed-off-by: Young Xiao <YangX92 at hotmail.com>
---
 drivers/gpu/drm/radeon/radeon_atombios.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index f422a8d..9121961 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -583,6 +583,12 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
 				ATOM_DEVICE_CV_SUPPORT)
 				continue;
 
+			if (con_obj_id >= ARRAY_SIZE(object_connector_convert)) {
+				DRM_ERROR("invalid con_obj_id %d for device tag 0x%04x\n",
+					  con_obj_id, le16_to_cpu(path->usDeviceTag));
+				continue;
+			}
+
 			/* IGP chips */
 			if ((rdev->flags & RADEON_IS_IGP) &&
 			    (con_obj_id ==
-- 
2.7.4



More information about the dri-devel mailing list