public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/tegra: Handle EDID allocation failures in tegra_output_connector_get_modes()
@ 2025-03-05 15:40 Wentao Liang
  2025-03-05 17:17 ` Jani Nikula
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-03-05 15:40 UTC (permalink / raw)
  To: thierry.reding, mperttunen, airlied, simona, jonathanh
  Cc: dri-devel, linux-tegra, linux-kernel, Wentao Liang, stable

The return values of `drm_edid_dup()` and `drm_edid_read_ddc()` must
be checked in `tegra_output_connector_get_modes()` to prevent NULL
pointer dereferences. If either function fails, the function should
immediately return 0, indicating that no display modes can be retrieved.

A proper implementation can be found in `vidi_get_modes()`, where the
return values are carefully validated, and the function returns 0 upon
failure.

Fixes: 98365ca74cbf ("drm/tegra: convert to struct drm_edid")
Cc: stable@vger.kernel.org # 6.12+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/gpu/drm/tegra/output.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 49e4f63a5550..360c4f83a4f8 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -39,6 +39,9 @@ int tegra_output_connector_get_modes(struct drm_connector *connector)
 	else if (output->ddc)
 		drm_edid = drm_edid_read_ddc(connector, output->ddc);
 
+	if (!drm_edid)
+		return 0;
+
 	drm_edid_connector_update(connector, drm_edid);
 	cec_notifier_set_phys_addr(output->cec,
 				   connector->display_info.source_physical_address);
-- 
2.42.0.windows.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-05 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 15:40 [PATCH] drm/tegra: Handle EDID allocation failures in tegra_output_connector_get_modes() Wentao Liang
2025-03-05 17:17 ` Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox