diff options
author | Arnd Bergmann <[email protected]> | 2024-04-09 16:00:57 +0200 |
---|---|---|
committer | Andrew Morton <[email protected]> | 2024-04-25 21:07:08 -0700 |
commit | 051e7503070179f2278c0d4fa7dee441adb558ca (patch) | |
tree | 7cea9d9163f5a870eb613ab55de613dcecd213f2 | |
parent | 597bc741e5ac2608e3ec0afd4256163879ab506b (diff) |
blktrace: convert strncpy() to strscpy_pad()
gcc-9 warns about a possibly non-terminated string copy:
kernel/trace/blktrace.c: In function 'do_blk_trace_setup':
kernel/trace/blktrace.c:527:2: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation]
Newer versions are fine here because they see the following explicit
nul-termination. Using strscpy_pad() avoids the warning and
simplifies the code a little. The padding helps give a clean
buffer to userspace.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnd Bergmann <[email protected]>
Acked-by: Justin Stitt <[email protected]>
Cc: Alexey Starikovskiy <[email protected]>
Cc: Bob Moore <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Lin Ming <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nicolas Schier <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>
Cc: "Richard Russon (FlatCap)" <[email protected]>
Cc: Steven Rostedt <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r-- | kernel/trace/blktrace.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index d5d94510afd3..8fd292d34d89 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -524,8 +524,7 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, if (!buts->buf_size || !buts->buf_nr) return -EINVAL; - strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); - buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0'; + strscpy_pad(buts->name, name, BLKTRACE_BDEV_SIZE); /* * some device names have larger paths - convert the slashes |