From: Dan Carpenter Date: Thu, 24 Oct 2019 17:42:53 +0000 (-0400) Subject: LU-9859 libcfs: Prevent harmless read underflow X-Git-Tag: 2.13.51~141 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=834341ee0de597c3004e6a11c696e3d7e337b1bc;p=fs%2Flustre-release.git LU-9859 libcfs: Prevent harmless read underflow Because this is a post-op instead of a pre-op, then it means we check if knl_buffer[-1] is a space. It doesn't really hurt anything, but it causes a static checker warning so let's fix it. Linux-commit: 134aecbc25fd77645baaea5467b2a7ed8e9d1ea7 Change-Id: I40fee264eb1ac461baa183f199b4e5e1b5eb26f5 Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/36567 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Shaun Tancheff Reviewed-by: Neil Brown Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index 926451f..81cb393 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -722,7 +722,7 @@ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, return -EFAULT; nob = strnlen(knl_buffer, usr_buffer_nob); - while (nob-- >= 0) /* strip trailing whitespace */ + while (--nob >= 0) /* strip trailing whitespace */ if (!isspace(knl_buffer[nob])) break;