summaryrefslogtreecommitdiff
path: root/drivers/sh
diff options
context:
space:
mode:
authorHongbo Li <lihongbo22@huawei.com>2024-09-02 05:45:34 +0300
committerJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>2024-09-26 18:25:29 +0300
commitc3e878ca7b6663d2ad77a6e17460fc47a2347f4a (patch)
tree51f43aa06953678b00c2d5cb0ce916f3c98ceef8 /drivers/sh
parent977fae6d611764d41de19b9ba01699b1618148f7 (diff)
downloadlinux-c3e878ca7b6663d2ad77a6e17460fc47a2347f4a.tar.xz
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 <lihongbo22@huawei.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Diffstat (limited to 'drivers/sh')
-rw-r--r--drivers/sh/intc/userimask.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/sh/intc/userimask.c b/drivers/sh/intc/userimask.c
index abe9091827cd..a363f77881d1 100644
--- a/drivers/sh/intc/userimask.c
+++ b/drivers/sh/intc/userimask.c
@@ -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