mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/debugfs: Accept "reset" with a trailing newline in edid_override
@ 2026-11-12 10:44 Arun Iyengar via B4 Relay
  2026-11-12 11:48 ` Jani Nikula
  0 siblings, 1 reply; 2+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-12 10:44 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Jani Nikula, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

Writing "reset" to a connector's edid_override debugfs file removes the
override, but only when exactly those five bytes are written. The
obvious

  echo reset > /sys/kernel/debug/dri/0/HDMI-A-1/edid_override

writes "reset\n", which is handed to drm_edid_override_set() as an EDID
and rejected with -EINVAL, leaving the override in place. A test
harness that cleared its override this way kept running on the
overridden EDID until the next reboot.

Accept a single trailing newline as well. An EDID is at least 128
bytes, so a six-byte "reset\n" can't be a valid override.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Found and tested on an Orange Pi 5 (RK3588S), with this change on a 7.3
based kernel: with the HDMI connector's own EDID written to
edid_override, "echo reset > edid_override" succeeds and edid_override
reads back empty, and "printf reset" (no newline) still succeeds. On
drm-misc-next the patch is build-tested only (arm64 and x86_64, W=1).

This patch was developed with Claude (Anthropic) as a coding assistant:
it wrote the code and the commit message, and I reviewed and tested it
as described above.
---
 drivers/gpu/drm/drm_debugfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index a72f9723d3a9..3c6290457fa3 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -569,7 +569,12 @@ static ssize_t edid_write(struct file *file, const char __user *ubuf,
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
-	if (len == 5 && !strncmp(buf, "reset", 5))
+	/*
+	 * An EDID is at least 128 bytes, so "reset" with the trailing newline
+	 * that "echo reset" adds can't be mistaken for one.
+	 */
+	if ((len == 5 || (len == 6 && buf[5] == '\n')) &&
+	    !strncmp(buf, "reset", 5))
 		ret = drm_edid_override_reset(connector);
 	else
 		ret = drm_edid_override_set(connector, buf, len);

---
base-commit: cb0a63f0c96e8ecb90199eeb99cc2a7fcfa703d4
change-id: 20261110-drm-debugfs-edid-reset-0504a20c67d1

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>



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

end of thread, other threads:[~2026-11-12 11:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 10:44 [PATCH] drm/debugfs: Accept "reset" with a trailing newline in edid_override Arun Iyengar via B4 Relay
2026-11-12 11:48 ` Jani Nikula

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

all inboxes | Powered by JetHome®