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-next>] [day] [month] [year] [list]
Message-ID: <20170201222331.GE40720@dtor-ws>
Date:   Wed, 1 Feb 2017 14:23:31 -0800
From:   Dmitry Torokhov <dmitry.torokhov@...il.com>
To:     Mark Brown <broonie@...nel.org>
Cc:     Thierry Reding <treding@...dia.com>,
        Jelle van der Waa <jelle@...aa.nl>,
        Linus Walleij <linus.walleij@...aro.org>,
        linux-kernel@...r.kernel.org
Subject: regulator_get_optional() no longer returning NULL?

Hi Mark,

It appears that [devm_]regulator_get_optional() and
[devm_]gpiod_get_optional() behave irritatingly differently. While the
latter returns NULL for non-existing GPIOs, the former started returning
-ENODEV instead of NULL, starting with commit below.

Why did we do that? It is much more convenient to write:

	data->vcc = devm_regulator_get_optional(dev. "vcc");
	if (IS_ERR(data->vcc))
		return ERR_PTR(data->vcc);
	...
	if (data->vcc)
		do_stuff();

vs.

	data->vcc = devm_regulator_get_optional(dev. "vcc");
	if (IS_ERR(data->vcc)) {
		error = ERR_PTR(data->vcc);
		if (error != -ENODEV && error != <list of vetted codes>)
			return error;

		data->vcc = NULL;
	}

I.e. it is nice to treat *all* codes returned by
devm_regulator_get_optional() as fatal and NULL as special instead of
vetting by hand (and having chance that list of vetted codes will bit
rot).

Can we please revert this patch?

Thanks!

-- 
Dmitry

commit ef60abbb6b406389245225ab4acfe73f66e7d92c
Author: Mark Brown <broonie@...aro.org>
Date:   Mon Sep 23 16:12:52 2013 +0100

    regulator: core: Always use return value when regulator_dev_lookup() fails

    Ensure that the return value is always set when we return now that the
    logic has changed for regulator_get_optional() so we don't get missing
    codes leaking out.

    Reported-by: Thierry Reding <treding@...dia.com>
    Tested-by: Thierry Reding <treding@...dia.com>
    Signed-off-by: Mark Brown <broonie@...aro.org>

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 088b41ac9506..a40055edaae4 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1263,12 +1263,13 @@ static struct regulator *_regulator_get(struct
device *dev, const char *id,
        if (rdev)
                goto found;
 
+       regulator = ERR_PTR(ret);
+
        /*
         * If we have return value from dev_lookup fail, we do not
         * expect to
         * succeed, so, quit with appropriate error value
         */
        if (ret && ret != -ENODEV) {
-               regulator = ERR_PTR(ret);
                goto out;
        }
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ