drm: remove the newline for CRC source name.
authorDingchen Zhang <dingchen.zhang@amd.com>
Mon, 10 Jun 2019 13:47:51 +0000 (09:47 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Feb 2020 15:36:02 +0000 (16:36 +0100)
[ Upstream commit 72a848f5c46bab4c921edc9cbffd1ab273b2be17 ]

userspace may transfer a newline, and this terminating newline
is replaced by a '\0' to avoid followup issues.

'len-1' is the index to replace the newline of CRC source name.

v3: typo fix (Sam)

v2: update patch subject, body and format. (Sam)

Cc: Leo Li <sunpeng.li@amd.com>
Cc: Harry Wentland <Harry.Wentland@amd.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Dingchen Zhang <dingchen.zhang@amd.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190610134751.14356-1-dingchen.zhang@amd.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/drm_debugfs_crc.c

index 2901b7944068de4fd169122a236cc94da420e95c..6858c80d2eb503db25664159994a08645659520e 100644 (file)
@@ -101,8 +101,8 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf,
        if (IS_ERR(source))
                return PTR_ERR(source);
 
-       if (source[len] == '\n')
-               source[len] = '\0';
+       if (source[len - 1] == '\n')
+               source[len - 1] = '\0';
 
        spin_lock_irq(&crc->lock);