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: <CAK5ve-K2DQq+KpAARMWw_RR=zmCpz92TikAivwMNWT5=n2iDBQ@mail.gmail.com>
Date:	Wed, 25 Jun 2014 15:30:13 -0700
From:	Bryan Wu <cooloney@...il.com>
To:	Johan Hovold <johan@...nel.org>
Cc:	Richard Purdie <rpurdie@...ys.net>,
	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-input@...r.kernel.org, lkml <linux-kernel@...r.kernel.org>,
	Linux LED Subsystem <linux-leds@...r.kernel.org>,
	Janne Kanniainen <janne.kanniainen@...il.com>,
	Jiri Kosina <jkosina@...e.cz>,
	Bjørn Mork <bjorn@...k.no>
Subject: Re: [PATCH 07/13] leds: netxbig: fix attribute-creation race

On Wed, Jun 25, 2014 at 10:08 AM, Johan Hovold <johan@...nel.org> wrote:
> Use the attribute groups of the led-class to create the sata attribute
> during probe in order to avoid racing with userspace.
>
> Signed-off-by: Johan Hovold <johan@...nel.org>
> ---
>  drivers/leds/leds-netxbig.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c
> index e97f443a6e07..8ab931b8fcd3 100644
> --- a/drivers/leds/leds-netxbig.c
> +++ b/drivers/leds/leds-netxbig.c
> @@ -293,10 +293,14 @@ static ssize_t netxbig_led_sata_show(struct device *dev,
>
>  static DEVICE_ATTR(sata, 0644, netxbig_led_sata_show, netxbig_led_sata_store);
>
> +static struct attribute *netxbig_led_attrs[] = {
> +       &dev_attr_sata.attr,
> +       NULL
> +};
> +ATTRIBUTE_GROUPS(netxbig_led);
> +
>  static void delete_netxbig_led(struct netxbig_led_data *led_dat)
>  {
> -       if (led_dat->mode_val[NETXBIG_LED_SATA] != NETXBIG_LED_INVALID_MODE)
> -               device_remove_file(led_dat->cdev.dev, &dev_attr_sata);
>         led_classdev_unregister(&led_dat->cdev);
>  }
>
> @@ -327,6 +331,12 @@ create_netxbig_led(struct platform_device *pdev,
>         led_dat->sata = 0;
>         led_dat->cdev.brightness = LED_OFF;
>         led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
> +       /*
> +        * If available, expose the SATA activity blink capability through
> +        * a "sata" sysfs attribute.
> +        */
> +       if (led_dat->mode_val[NETXBIG_LED_SATA] != NETXBIG_LED_INVALID_MODE)
> +               led_dat->cdev.groups = netxbig_led_groups;
>         led_dat->mode_addr = template->mode_addr;
>         led_dat->mode_val = template->mode_val;
>         led_dat->bright_addr = template->bright_addr;
> @@ -335,18 +345,6 @@ create_netxbig_led(struct platform_device *pdev,
>         led_dat->num_timer = pdata->num_timer;
>
>         ret = led_classdev_register(&pdev->dev, &led_dat->cdev);

Let's just "return led_classdev_register(&pdev->dev, &led_dat->cdev);"
and remove "ret"

I will handle this trivial change.

-Bryan
> -       if (ret < 0)
> -               return ret;
> -
> -       /*
> -        * If available, expose the SATA activity blink capability through
> -        * a "sata" sysfs attribute.
> -        */
> -       if (led_dat->mode_val[NETXBIG_LED_SATA] != NETXBIG_LED_INVALID_MODE) {
> -               ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata);
> -               if (ret)
> -                       led_classdev_unregister(&led_dat->cdev);
> -       }
>
>         return ret;
>  }
> --
> 1.8.5.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