Skip to content

Commit c3e878c

Browse files
Hongbo Liglaubitz
authored andcommitted
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: Hongbo Li <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Reviewed-by: John Paul Adrian Glaubitz <[email protected]> Signed-off-by: John Paul Adrian Glaubitz <[email protected]>
1 parent 977fae6 commit c3e878c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/sh/intc/userimask.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ store_intc_userimask(struct device *dev,
3232
const char *buf, size_t count)
3333
{
3434
unsigned long level;
35+
int ret;
3536

36-
level = simple_strtoul(buf, NULL, 10);
37+
ret = kstrtoul(buf, 10, &level);
38+
if (ret != 0)
39+
return ret;
3740

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

0 commit comments

Comments
 (0)