Skip to contentSkip to conversation

gma500/cdv: fix null pointer dereference in cdv_intel_dp_get_modes

PATCH New Chenyuan Yang 1 participant 1 message Apr 7, 2025

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

PATCH 1/1 gma500/cdv: fix null pointer dereference in cdv_intel_dp_get_modes

In cdv_intel_dp_get_modes(), the return value of drm_mode_duplicate() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_mode_duplicate(). Add a check to avoid npd.

This is similar to the fix commit cb520c3f366c
("drm/gma500: fix null pointer dereference in cdv_intel_lvds_get_modes").

This is found by our static analysis tool KNighter.

Fixes d112a8163f83 ("gma500/cdv: Add eDP support")
---
 drivers/gpu/drm/gma500/cdv_intel_dp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/gma500/cdv_intel_dp.c +3 -0
index c85143792019..4bd66804bc09 100644
@@ -1767,6 +1767,9 @@ static int cdv_intel_dp_get_modes(struct drm_connector *connector)
 		if (intel_dp->panel_fixed_mode != NULL) {
 			struct drm_display_mode *mode;
 			mode = drm_mode_duplicate(dev, intel_dp->panel_fixed_mode);
+			if (!mode)
+				return ret;
+
 			drm_mode_probed_add(connector, mode);
 			return 1;
 		}
Signature · 1 line
2.34.1