Skip to contentSkip to conversation

drm/debugfs: Accept "reset" with a trailing newline in edid_override

PATCH New Arun Iyengar 1 participant 1 message Nov 19

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

PATCH v3 1/1 drm/debugfs: Accept "reset" with a trailing newline in edid_override

Writing "reset" to edid_override removes the override only for exactly those five bytes, so "echo reset > edid_override" fails with -EINVAL.

Compare with sysfs_streq() on a NUL-terminated copy.

---
Tested on an Orange Pi 5 (7.3-based kernel with KASAN) on its DP
connector: setting and reading back the EDID, both reset forms, and malformed and oversized writes (rejected, override unchanged).

Developed with Claude (Anthropic), which wrote the code and the commit
message. I reviewed every change.
---
Changes in v3:
- Drop the unrelated length check (Jani Nikula)
- Link to v2: https://patch.msgid.link/[email protected]

---
 drivers/gpu/drm/drm_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_debugfs.c +2 -2
index a72f9723d3a9..77b22730d091 100644
@@ -565,11 +565,11 @@ static ssize_t edid_write(struct file *file, const char __user *ubuf,
 	char *buf;
 	int ret;
 
-	buf = memdup_user(ubuf, len);
+	buf = memdup_user_nul(ubuf, len);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
-	if (len == 5 && !strncmp(buf, "reset", 5))
+	if (sysfs_streq(buf, "reset"))
 		ret = drm_edid_override_reset(connector);
 	else
 		ret = drm_edid_override_set(connector, buf, len);

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

Best regards,

Signature · 1 line
Arun Iyengar <[email protected]>