Skip to contentSkip to conversation

x86/boot: Replace simple_strtoull in parse_gb_huge_pages

PATCH Superseded Thorsten Blum 1 participant 1 message Jan 12 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/boot: Replace simple_strtoull in parse_gb_huge_pages

Replace simple_strtoull() with the recommended boot_kstrtoul() for parsing the 'hugepages=' boot parameter. Unlike simple_strtoull(), which returns an unsigned long long, boot_kstrtoul() converts the string directly to an unsigned long and avoids implicit casting.

Check the return value of boot_kstrtoul() and warn about invalid values.

---
 arch/x86/boot/compressed/kaslr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/boot/compressed/kaslr.c +2 -1
index 3b0948ad449f..e6c44a0d3640 100644
@@ -219,7 +219,8 @@ static void parse_gb_huge_pages(char *param, char *val)
 
 	if (!strcmp(param, "hugepages") && gbpage_sz) {
 		p = val;
-		max_gb_huge_pages = simple_strtoull(p, &p, 0);
+		if (boot_kstrtoul(p, 0, &max_gb_huge_pages))
+			warn("Failed to parse boot parameter hugepages\n");
 		return;
 	}
 }
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4