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: <20100402160058.GE27613@sirena.org.uk>
Date:	Fri, 2 Apr 2010 17:00:59 +0100
From:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
To:	Jerome Oufella <jerome.oufella@...oirfairelinux.com>
Cc:	Liam Girdwood <lrg@...mlogic.co.uk>,
	lm-sensors <lm-sensors@...sensors.org>,
	linux-kernel@...r.kernel.org
Subject: Re: regulator: regulator_get behaviour without CONFIG_REGULATOR set

On Fri, Apr 02, 2010 at 11:47:50AM -0400, Jerome Oufella wrote:

Please fix your mail client to word wrap paragraphs, I've manually fixed
this up here.

> Working on drivers/hwmon/sht15.c, I noticed it would return bogus
> temperatures in my case, where CONFIG_REGULATOR is not set.

> This is due to the following section in drivers/hwmon/sht15.c:
> 
> /* If a regulator is available, query what the supply voltage actually is!*/
>         data->reg = regulator_get(data->dev, "vcc");
>         if (!IS_ERR(data->reg)) {
>             ...

> Looking at consumer.h, it appears that regulator_get() returns a
> pointer to its second argument when CONFIG_REGULATOR is not set.

Right, it's just returning something that won't match IS_ERR().

> What would be the proper way to determine if the returned value is a
> valid regulator ?  Would it be safe to check it against the 2nd
> argument ?

You're asking the wrong question here.  The problem here is not that the
regulator got stubbed out, the problem is that the sht15 driver is not
checking the return value of regulator_get_voltage() and so is trying to
use the error code that was returned as a voltage, with predictably poor
results.  It is this function that the driver needs to check, not
regulator_get().  There are a range of reasons why an error might be
returned when querying the voltage, all of which would cause the same
result.

It is not sensible to check the return code of regulator_get() for
anything other than IS_ERR().
--
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