Linux-sh Archive mirror
 help / color / mirror / Atom feed
From: Hongbo Li <lihongbo22@huawei.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: <ysato@users.sourceforge.jp>, <dalias@libc.org>,
	<glaubitz@physik.fu-berlin.de>, <linux-sh@vger.kernel.org>
Subject: Re: [PATCH -next] sh: intc: replace simple_strtoul to kstrtoul
Date: Sat, 31 Aug 2024 10:03:04 +0800	[thread overview]
Message-ID: <98c7b473-0b2b-4e47-83f6-35d9f417bb01@huawei.com> (raw)
In-Reply-To: <CAMuHMdX-rRP3BCcm2mxJKjvSoYKnsLudMuFqArQzzVOQ8fv8aQ@mail.gmail.com>



On 2024/8/30 16:22, Geert Uytterhoeven wrote:
> Hi Hongbo,
> 
> On Fri, Aug 30, 2024 at 9:56 AM Hongbo Li <lihongbo22@huawei.com> 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 <lihongbo22@huawei.com>
> 
> 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
> 

      reply	other threads:[~2024-08-31  2:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30  8:04 [PATCH -next] sh: intc: replace simple_strtoul to kstrtoul Hongbo Li
2024-08-30  8:16 ` John Paul Adrian Glaubitz
2024-08-30  8:22 ` Geert Uytterhoeven
2024-08-31  2:03   ` Hongbo Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98c7b473-0b2b-4e47-83f6-35d9f417bb01@huawei.com \
    --to=lihongbo22@huawei.com \
    --cc=dalias@libc.org \
    --cc=geert@linux-m68k.org \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-sh@vger.kernel.org \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).