]> www.infradead.org Git - users/hch/dma-mapping.git/commitdiff
sh: intc: Replace simple_strtoul() with kstrtoul()
authorHongbo Li <lihongbo22@huawei.com>
Mon, 2 Sep 2024 02:45:34 +0000 (10:45 +0800)
committerJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Thu, 26 Sep 2024 15:25:29 +0000 (17:25 +0200)
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>
drivers/sh/intc/userimask.c

index abe9091827cd680f3264ce2847c8220fbc6b71b0..a363f77881d1e16f35aedff2f643e6e1fb42f90d 100644 (file)
@@ -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