module: remove use of uninitialized variable len
authorTom Rix <trix@redhat.com>
Mon, 17 Apr 2023 23:09:57 +0000 (19:09 -0400)
committerLuis Chamberlain <mcgrof@kernel.org>
Tue, 18 Apr 2023 18:36:24 +0000 (11:36 -0700)
clang build reports
kernel/module/stats.c:307:34: error: variable
  'len' is uninitialized when used here [-Werror,-Wuninitialized]
        len = scnprintf(buf + 0, size - len,
                                        ^~~
At the start of this sequence, neither the '+ 0', nor the '- len' are needed.
So remove them and fix using 'len' uninitalized.

Fixes: df3e764d8e5c ("module: add debug stats to help identify memory pressure")
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
kernel/module/stats.c

index a1f5454..6eeb35c 100644 (file)
@@ -302,7 +302,7 @@ static ssize_t read_file_mod_stats(struct file *file, char __user *user_buf,
                return -ENOMEM;
 
        /* The beginning of our debug preamble */
-       len = scnprintf(buf + 0, size - len, "%25s\t%u\n", "Mods ever loaded", live_mod_count);
+       len = scnprintf(buf, size, "%25s\t%u\n", "Mods ever loaded", live_mod_count);
 
        len += scnprintf(buf + len, size - len, "%25s\t%u\n", "Mods failed on kread", fkreads);