[PATCH] gma500/cdv: fix null pointer dereference in cdv_intel_dp_get_modes

Chenyuan Yang chenyuan0y at gmail.com
Mon Apr 7 14:58:47 UTC 2025


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.

Signed-off-by: Chenyuan Yang <chenyuan0y at gmail.com>
Fixes: d112a8163f83 ("gma500/cdv: Add eDP support")
---
 drivers/gpu/drm/gma500/cdv_intel_dp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c
index c85143792019..4bd66804bc09 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_dp.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c
@@ -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;
 		}
-- 
2.34.1



More information about the dri-devel mailing list