Skip to contentSkip to conversation

module: remove use of uninitialized variable len

PATCH Applied Tom Rix 2 participants 2 messages Apr 17, 2023 Module support

lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 module: remove use of uninitialized variable len

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 0d4ab68ce983 ("module: add debug stats to help identify memory pressure")
---
 kernel/module/stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/module/stats.c +1 -1
index d9b9bccf4256..f0619170bd3d 100644
@@ -304,7 +304,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);
 
Signature · 1 line
2.27.0
maintainer Applied
#1 lore raw
Quoted 11 lines · Tom Rix

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 0d4ab68ce983 ("module: add debug stats to help identify memory pressure")

---

Thanks, applied and pushed!

Luis