lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEqHmAtmHjEJUdvkBPhF5PzP4V_xDc5owLJpp0DENsXLs_ynxQ@mail.gmail.com>
Date:	Tue, 10 Jan 2012 00:11:33 +0000
From:	dd diasemi <dd.diasemi@...il.com>
To:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: drivers/regulator/core.c: Fixes mapping inside
 regulator_mode_to_status() and makes it returning -EINVAL on invalid input.

On Mon, Jan 9, 2012 at 8:07 PM, Mark Brown
<broonie@...nsource.wolfsonmicro.com> wrote:
> On Mon, Jan 09, 2012 at 07:20:50PM +0000, dd diasemi wrote:
>> On Mon, Jan 9, 2012 at 4:14 PM, Mark Brown
>
>> >>       default:
>> >> -             return 0;
>> >> +             return -EINVAL;
>
>> > This behaviour is deliberate.
>
>> For this moment, the only usage is in one file in
>> wm831x_aldo_get_status() and wm831x_gp_ldo_get_status():
>>       ret = wm831x_aldo_get_mode(rdev);
>>       if (ret < 0)
>>               return ret;
>>       else
>>               return regulator_mode_to_status(ret);
>
>> The usage mistreats the signed value 'ret' as wm831x_aldo_get_mode()
>> always returns 0 on communication error. It effects in response as if
>> the regulator was off.
>
>> If that behaviour is deliberate, I would suggest to make it explicit:
>>       default:
>> -             return 0;
>> +             return REGULATOR_STATUS_OFF;
>
> That's not the deliberate behaviour, the deliberate behaviour is to
> return no mode if we didn't find one.

I am focusing now on regulator_mode_to_status(). It returns regulator
status inside int value. If driver passes 0 to the function (eg. in
case of communication failure), which is not a valid mode, either it
may return REGULATOR_STATUS_OFF (0) as a valid status or it may return
an error code.

I am aware, that dealing with communication problem is rather in
driver responsibility, than the framework itself, but keeping things
clear is also important, especially for framework.

Making regulator_mode_to_status() returning an error allows to
simplify its usage:
	ret = regulator_mode_to_status(regulator_get_mode(rdev));
	if (ret < 0)
		ret = -EIO;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ