Commit c3e878ca authored by Hongbo Li's avatar Hongbo Li Committed by John Paul Adrian Glaubitz
Browse files

sh: intc: Replace simple_strtoul() with kstrtoul()



The function simple_strtoul() performs no error checking
in scenarios where the input value overflows the intended
output variable.

We can replace the use of simple_strtoul() with the safer
alternative kstrtoul(). This also allows us to print an
error message in case of failure.

Signed-off-by: default avatarHongbo Li <lihongbo22@huawei.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
parent 977fae6d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -32,8 +32,11 @@ store_intc_userimask(struct device *dev,
		     const char *buf, size_t count)
{
	unsigned long level;
	int ret;

	level = simple_strtoul(buf, NULL, 10);
	ret = kstrtoul(buf, 10, &level);
	if (ret != 0)
		return ret;

	/*
	 * Minimal acceptable IRQ levels are in the 2 - 16 range, but