lkml.org 
[lkml]   [2015]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 15/20] staging/lustre/libcfs: get rid of debugfs/lnet/console_backoff
From
Date

On Jul 8, 2015, at 4:28 AM, Dan Carpenter wrote:

> On Mon, Jul 06, 2015 at 12:48:53PM -0400, green@linuxhacker.ru wrote:
>> +static int param_set_uint_minmax(const char *val,
>> + const struct kernel_param *kp,
>> + unsigned int min, unsigned int max)
>> +{
>> + unsigned int num;
>> + int ret;
>> +
>> + if (!val)
>> + return -EINVAL;
>> + ret = kstrtouint(val, 0, &num);
>> + if (ret == -EINVAL || num < min || num > max)
> ^^^
> Smatch is smart enough to know that "num" can be uninitialized here on
> some paths. It doesn't generate a warning yet because a lot of the
> kernel has error paths where we mostly assume things won't fail.
>
> It should probably be:
>
> ret = kstrtouint(val, 0, &num);
> if (ret)
> return ret;
> if (num < min || num > max)
> return -EINVAL;

Hm, indeed kstrtouint can return errors other than -EINVAL.
In reality this code comes from net/sunrpc/xprtsock.c
and I failed to see the problem there while copying.

This also suggests that the type is might be enough in demand
to make it generic so that people don't reimplement it themselves?

Thanks!

Bye,
Oleg



\
 
 \ /
  Last update: 2015-07-08 16:01    [W:1.340 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site