Commit 33eea63f authored by Thorsten Blum's avatar Thorsten Blum Committed by Herbert Xu
Browse files

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: default avatarThorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 1a098379
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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;
}