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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 24 Sep 2013 10:35:50 -0700
From:	Bryan Wu <cooloney@...il.com>
To:	Josh Wu <josh.wu@...el.com>
Cc:	"rpurdie@...ys.net" <rpurdie@...ys.net>,
	Linux LED Subsystem <linux-leds@...r.kernel.org>,
	lkml <linux-kernel@...r.kernel.org>, devicetree@...r.kernel.org
Subject: Re: [PATCH] leds-gpio: of: led should not be created if its status is disabled

On Tue, Sep 24, 2013 at 1:04 AM, Josh Wu <josh.wu@...el.com> wrote:
> now the leds-gpio driver will create every child led node without
> checking the status is disabled or not.
>
> for example, if we have a led node like d3, and its status is disabled:
>         leds {
>                 d3 {
>                         label = "d3";
>                         gpios = <&pioE 24 0>;
>                         status = "disabled";
>                 };
>         };
>
> we except the d3 should not be created. And the gpios should not be
> request as well.
>
> But current driver will create d3 and request its gpio.
>
> This patch fix this by using for_each_available_child_of_node() to
> enumerate all child nodes. So the disabled node will be inavilable.
>
> Signed-off-by: Josh Wu <josh.wu@...el.com>
> ---
>  drivers/leds/leds-gpio.c |   14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index e8b01e5..9bb4e04 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -167,23 +167,23 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
>  {
>         struct device_node *np = pdev->dev.of_node, *child;
>         struct gpio_leds_priv *priv;
> -       int count, ret;
> +       int count = 0, ret;
>
>         /* count LEDs in this device, so we know how much to allocate */
> -       count = of_get_child_count(np);

Can we invent a new API named of_get_available_child_count()? So we
just need to replace the API here? Besides this, I'm OK for this patch
actually.

Thanks,
-Bryan

> -       if (!count)
> -               return ERR_PTR(-ENODEV);
> -
> -       for_each_child_of_node(np, child)
> +       for_each_available_child_of_node(np, child) {
> +               count++;
>                 if (of_get_gpio(child, 0) == -EPROBE_DEFER)
>                         return ERR_PTR(-EPROBE_DEFER);
> +       }
> +       if (!count)
> +               return ERR_PTR(-ENODEV);
>
>         priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count),
>                         GFP_KERNEL);
>         if (!priv)
>                 return ERR_PTR(-ENOMEM);
>
> -       for_each_child_of_node(np, child) {
> +       for_each_available_child_of_node(np, child) {
>                 struct gpio_led led = {};
>                 enum of_gpio_flags flags;
>                 const char *state;
> --
> 1.7.9.5
>
--
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