Re: [PATCH -next] sh: intc: replace simple_strtoul to kstrtoul

Hongbo Li <[email protected]>
Newsgroups gmane.linux.ports.sh.devel
Message-ID <[email protected]>

On 2024/8/30 16:22, Geert Uytterhoeven wrote:
> Hi Hongbo,
> 
> On Fri, Aug 30, 2024 at 9:56 AM Hongbo Li <[email protected]> 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]>
> 
> Thanks for your patch!
> 
>> --- a/drivers/sh/intc/userimask.c
>> +++ b/drivers/sh/intc/userimask.c
>> @@ -33,7 +33,8 @@ store_intc_userimask(struct device *dev,
>>   {
>>          unsigned long level;
>>
>> -       level = simple_strtoul(buf, NULL, 10);
>> +       if (kstrtoul(buf, 10, &level))
>> +               return -EINVAL;
> 
> Please pass the error code returned by kstrtoul() instead of hardcoding
> -EINVAL.
> 
Thanks for reviewing, I'll make a change.

Thanks,
Hongbo
>>
>>          /*
>>           * Minimal acceptable IRQ levels are in the 2 - 16 range, but
> 
> Gr{oetje,eeting}s,
> 
>                          Geert
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.