aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/fips.c
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2025-09-16 00:12:45 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2025-10-17 16:03:57 +0800
commit33eea63ff9c6abf26236dcad41165d3cc499d905 (patch)
tree8dfa6aa564386d082e3243bc52e59b20ff46de21 /crypto/fips.c
parent1a098379f28b05996603888ff7dd508e5773d5d9 (diff)
downloadtip-33eea63ff9c6abf26236dcad41165d3cc499d905.tar.gz
crypto: fips - replace simple_strtol with kstrtoint to improve fips_enable
Replace simple_strtol() with the recommended kstrtoint() for parsing the 'fips=' boot parameter. Unlike simple_strtol(), which returns a long, kstrtoint() converts the string directly to an integer and avoids implicit casting. Check the return value of kstrtoint() and reject invalid values. This adds error handling while preserving existing behavior for valid values, and removes use of the deprecated simple_strtol() helper. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/fips.c')
-rw-r--r--crypto/fips.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/fips.c b/crypto/fips.c
index e88a604cb42b59..65d2bc070a2636 100644
--- a/crypto/fips.c
+++ b/crypto/fips.c
@@ -24,7 +24,10 @@ EXPORT_SYMBOL_GPL(fips_fail_notif_chain);
/* Process kernel command-line parameter at boot time. fips=0 or fips=1 */
static int fips_enable(char *str)
{
- fips_enabled = !!simple_strtol(str, NULL, 0);
+ if (kstrtoint(str, 0, &fips_enabled))
+ return 0;
+
+ fips_enabled = !!fips_enabled;
pr_info("fips mode: %s\n", str_enabled_disabled(fips_enabled));
return 1;
}