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: <20150106120012.GW2634@sirena.org.uk>
Date:	Tue, 6 Jan 2015 12:00:12 +0000
From:	Mark Brown <broonie@...nel.org>
To:	Gregory CLEMENT <gregory.clement@...e-electrons.com>
Cc:	Liam Girdwood <lgirdwood@...il.com>, linux-kernel@...r.kernel.org,
	Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>,
	Ezequiel Garcia <ezequiel.garcia@...e-electrons.com>,
	Maxime Ripard <maxime.ripard@...e-electrons.com>,
	Boris BREZILLON <boris.brezillon@...e-electrons.com>,
	Lior Amsalem <alior@...vell.com>,
	Tawfik Bayouk <tawfik@...vell.com>,
	Nadav Haklai <nadavh@...vell.com>, linux-ide@...r.kernel.org
Subject: Re: [PATCH 1/2] regulator: core: Add a sanity check on the
 regulator_ enable/disable functions

On Tue, Jan 06, 2015 at 12:36:02PM +0100, Gregory CLEMENT wrote:
> Hi Mark,
> 
> On 29/12/2014 16:40, Mark Brown wrote:
> > On Fri, Dec 26, 2014 at 06:26:38PM +0100, Gregory CLEMENT wrote:

> > No, especially in the case of regulator_enable() this is deliberate -
> > we're trying to ensure that if people are using regulators they're being
> > careful about it, checking error codes and so on.  I'd really want to

> OK so at least we should check that the pointer is not NULL before using it
> and inform the user of it by using a WARNING() or even a BUG() instead of
> just let the kernel crash latter.

Just crashing on the NULL is just about as good in terms of
discoverabilty and any consumer that is assuming NULL is not a valid
regulator is buggy in any case, any non-error pointer could be a valid
regulator as far as users are concerned.  

> > see some persuasive use case for this.  What you're saying here sounds
> > like the consumer shouldn't be treating the regulator as optional at
> > all but should instead be using a normal regulator.

> Being able to deal with NULL pointer in the disable function is convenient
> and is done in other similar subsystems such as phy or clk for example. Instead
> of having a check on the NULL pointer in each driver, it seems more logical to
> do it directly in the disable function.

This really only applies if it's likely that some thing that always gets
used if it's there might be missing which isn't the case for regulators,
it's not at all common to have power supplies that might be missing and
if they are missing NULL isn't a good way to track them.

If you're having problems with this and need workarounds in the core to
make your driver code look OK that sounds like things are working since
it sounds like the driver code is probably abusing the API here.

Download attachment "signature.asc" of type "application/pgp-signature" (474 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ