Re: [PATCH 05/11] leds: trigger: netdev: introduce validating requested mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> @@ -168,7 +174,7 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
>  				     size_t size, enum led_trigger_netdev_modes attr)
>  {
>  	struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
> -	unsigned long state;
> +	unsigned long state, new_mode = trigger_data->mode;
>  	int ret;
>  	int bit;
>  
> @@ -186,12 +192,18 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
>  		return -EINVAL;
>  	}
>  
> -	cancel_delayed_work_sync(&trigger_data->work);
> -
>  	if (state)
> -		set_bit(bit, &trigger_data->mode);
> +		set_bit(bit, &new_mode);
>  	else
> -		clear_bit(bit, &trigger_data->mode);
> +		clear_bit(bit, &new_mode);
> +
> +	ret = validate_requested_mode(trigger_data, new_mode);
> +	if (ret)
> +		return ret;
> +
> +	cancel_delayed_work_sync(&trigger_data->work);
> +
> +	trigger_data->mode = new_mode;
>  
>  	set_baseline_state(trigger_data);

I think you need to hold the trigger_data lock here, otherwise there
are potential race conditions.

    Andrew



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux