From: Arun Iyengar <[email protected]>

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.

Suggested-by: Jani Nikula <[email protected]>
Signed-off-by: Arun Iyengar <[email protected]>
---
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(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index a72f9723d3a9..77b22730d091 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -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,
--  
Arun Iyengar <[email protected]>


Reply via email to