Re: [PATCH -next v3] sh: intc: replace simple_strtoul to kstrtoul
John Paul Adrian Glaubitz <[email protected]>
| Newsgroups | gmane.linux.ports.sh.devel |
|---|---|
| Message-ID | <399afcfa62ead32000837c6276d1243263449880.camel@physik.fu-berlin.de> |
On Mon, 2024-09-02 at 10:45 +0800, Hongbo Li wrote: > 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 the simple_strtoul with the safer > alternatives kstrtoul. For fail case, we also print the extra > message. > > Signed-off-by: Hongbo Li <[email protected]> > > --- > v3: > - Separate declaration and assignment to make it more consistent. > > v2: https://lore.kernel.org/all/[email protected]/T/ > - Pass the error code returned by kstrtoul() suggested by Geert. > > v1: https://lore.kernel.org/all/[email protected]/T/ > --- > drivers/sh/intc/userimask.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > 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 Reviewed-by: John Paul Adrian Glaubitz <[email protected]> Thanks, I will pick this up later today. Sorry for being super late. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913