Search Linux Wireless

Re: [PATCH 2/2] rfkill: use strict_strtoul

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

 



On Saturday 02 August 2008, Henrique de Moraes Holschuh wrote:
> Switch sysfs parsing to something that actually works properly.
> 
> Signed-off-by: Henrique de Moraes Holschuh <hmh@xxxxxxxxxx>
> Cc: Ivo van Doorn <IvDoorn@xxxxxxxxx>

Acked-by: Ivo van Doorn <IvDoorn@xxxxxxxxx>

> ---
>  net/rfkill/rfkill.c |   16 ++++++++++++----
>  1 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
> index 35a9994..2ec6312 100644
> --- a/net/rfkill/rfkill.c
> +++ b/net/rfkill/rfkill.c
> @@ -352,12 +352,16 @@ static ssize_t rfkill_state_store(struct device *dev,
>  				  const char *buf, size_t count)
>  {
>  	struct rfkill *rfkill = to_rfkill(dev);
> -	unsigned int state = simple_strtoul(buf, NULL, 0);
> +	unsigned long state;
>  	int error;
>  
>  	if (!capable(CAP_NET_ADMIN))
>  		return -EPERM;
>  
> +	error = strict_strtoul(buf, 0, &state);
> +	if (error)
> +		return error;
> +
>  	/* RFKILL_STATE_HARD_BLOCKED is illegal here... */
>  	if (state != RFKILL_STATE_UNBLOCKED &&
>  	    state != RFKILL_STATE_SOFT_BLOCKED)
> @@ -385,7 +389,7 @@ static ssize_t rfkill_claim_store(struct device *dev,
>  				  const char *buf, size_t count)
>  {
>  	struct rfkill *rfkill = to_rfkill(dev);
> -	bool claim = !!simple_strtoul(buf, NULL, 0);
> +	unsigned long claim;
>  	int error;
>  
>  	if (!capable(CAP_NET_ADMIN))
> @@ -394,6 +398,10 @@ static ssize_t rfkill_claim_store(struct device *dev,
>  	if (rfkill->user_claim_unsupported)
>  		return -EOPNOTSUPP;
>  
> +	error = strict_strtoul(buf, 0, &claim);
> +	if (error)
> +		return error;
> +
>  	/*
>  	 * Take the global lock to make sure the kernel is not in
>  	 * the middle of rfkill_switch_all
> @@ -402,7 +410,7 @@ static ssize_t rfkill_claim_store(struct device *dev,
>  	if (error)
>  		return error;
>  
> -	if (rfkill->user_claim != claim) {
> +	if (!!rfkill->user_claim != !!claim) {
>  		if (!claim) {
>  			mutex_lock(&rfkill->mutex);
>  			rfkill_toggle_radio(rfkill,
> @@ -410,7 +418,7 @@ static ssize_t rfkill_claim_store(struct device *dev,
>  					    0);
>  			mutex_unlock(&rfkill->mutex);
>  		}
> -		rfkill->user_claim = claim;
> +		rfkill->user_claim = !!claim;
>  	}
>  
>  	mutex_unlock(&rfkill_mutex);


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux