Skip to contentSkip to conversation

drm/edid: fix a possible null pointer dereference

PATCH In review Ma Ke 2 participants 2 messages Oct 11, 2023

Subsystems (2)
lore
Share & tools
lore

Ma Ke

author
#0 lore raw

PATCH 1/1 drm/edid: fix a possible null pointer dereference

In drm_mode_std(), the return value of drm_gtf_mode(), drm_gtf_mode() and drm_cvt_mode() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_gtf_mode(), drm_gtf_mode() and drm_cvt_mode(). Add a check to avoid null point dereference.

---
 drivers/gpu/drm/drm_edid.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_edid.c +2 -0
index 340da8257b51..e2c154c2b896 100644
@@ -3381,6 +3381,8 @@ static struct drm_display_mode *drm_mode_std(struct drm_connector *connector,
 				    false);
 		break;
 	}
+	if (!mode)
+		return NULL;
 	return mode;
 }
 
Signature · 1 line
2.37.2
#1 lore raw
Quoted 16 lines · Ma Ke

In drm_mode_std(), the return value of drm_gtf_mode(), drm_gtf_mode() and drm_cvt_mode() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_gtf_mode(), drm_gtf_mode() and drm_cvt_mode(). Add a check to avoid null point dereference.

---
 drivers/gpu/drm/drm_edid.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 340da8257b51..e2c154c2b896 100644

drivers/gpu/drm/drm_edid.c static struct drm_display_mode *drm_mode_std(struct drm_connector *connector, · line 3385

Quoted 5 lines
drivers/gpu/drm/drm_edid.c +2 -0
@@ -3381,6 +3381,8 @@ static struct drm_display_mode *drm_mode_std(struct drm_connector *connector,
 				    false);
 		break;
 	}
+	if (!mode)
+		return NULL;

This doesn't change anything.

BR,
Jani.

Quoted 2 lines
drivers/gpu/drm/drm_edid.c +0 -0
 	return mode;
 }
Signature · 1 line
Jani Nikula, Intel