[PATCH v2] staging: speakup: remove simple_strtoul()
Gabriel Fedel
fedel at fedel.net.br
Thu May 31 11:27:42 EDT 2018
Hello Greg,
Em 27-05-2018 09:46, Greg KH escreveu:
> On Sat, May 26, 2018 at 04:03:35PM -0300, Gabriel Fedel wrote:
>> Replace simple_strtoul() with kstrtoul(), because simple_strtoul() is
>> obsolete.
>>
>> kstrtoul and simple_strtoul are not equal, so some new code was
>> inserted:
>>
>> It was necessary to pass to kstrtoul just number part (new variable num).
>>
>> temp variable was setted manually (to position after cp number part).
>>
>> Signed-off-by: Gabriel Fedel <fedel at fedel.net.br>
>> ---
>> Changes since first patch:
>>
>> Fix C error
>> Change the way to use kstrtoul (on first patch just substitue simple_strtoul by
>> kstrtoul)
>>
>> ---
>> drivers/staging/speakup/kobjects.c | 27 +++++++++++++++++++++++++--
>> 1 file changed, 25 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
>> index f1f9022..50dc456 100644
>> --- a/drivers/staging/speakup/kobjects.c
>> +++ b/drivers/staging/speakup/kobjects.c
>> @@ -117,6 +117,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
>> char *outptr = NULL; /* Will hold keyword or desc. */
>> char *temp = NULL;
>> char *desc = NULL;
>> + char *num = NULL; /* The number part of cp */
>> ssize_t retval = count;
>> unsigned long flags;
>> unsigned long index = 0;
>> @@ -154,7 +155,17 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
>> continue;
>> }
>>
>> - index = simple_strtoul(cp, &temp, 10);
>> + i = 0;
>> + while (isdigit(*(cp + i)))
>> + i = i + 1;
>> + temp = cp + i;
>> +
>> + num = kmalloc(i + 2, GFP_ATOMIC);
>> + strscpy(num, cp, i + 1);
>> +
>> + if (kstrtoul(num, 10, &index) != 0)
>> + pr_warn("overflow or parsing error has occurred");
>
> If you have to go through the string twice, that's a huge sign that
> something is wrong. This "conversion" is not correct at all :(
Thank you for review.
I can't see the problem with this code, Could you point me the error?
>
> greg k-h
>
Gabiel
More information about the Speakup
mailing list