diff options
Diffstat (limited to 'net/rfkill')
-rw-r--r-- | net/rfkill/core.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 79693fe2001e..6896c0b45b4a 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c | |||
@@ -648,15 +648,26 @@ static ssize_t rfkill_state_store(struct device *dev, | |||
648 | struct device_attribute *attr, | 648 | struct device_attribute *attr, |
649 | const char *buf, size_t count) | 649 | const char *buf, size_t count) |
650 | { | 650 | { |
651 | /* | 651 | struct rfkill *rfkill = to_rfkill(dev); |
652 | * The intention was that userspace can only take control over | 652 | unsigned long state; |
653 | * a given device when/if rfkill-input doesn't control it due | 653 | int err; |
654 | * to user_claim. Since user_claim is currently unsupported, | 654 | |
655 | * we never support changing the state from userspace -- this | 655 | if (!capable(CAP_NET_ADMIN)) |
656 | * can be implemented again later. | 656 | return -EPERM; |
657 | */ | 657 | |
658 | err = strict_strtoul(buf, 0, &state); | ||
659 | if (err) | ||
660 | return err; | ||
661 | |||
662 | if (state != RFKILL_USER_STATE_SOFT_BLOCKED && | ||
663 | state != RFKILL_USER_STATE_UNBLOCKED) | ||
664 | return -EINVAL; | ||
665 | |||
666 | mutex_lock(&rfkill_global_mutex); | ||
667 | rfkill_set_block(rfkill, state == RFKILL_USER_STATE_SOFT_BLOCKED); | ||
668 | mutex_unlock(&rfkill_global_mutex); | ||
658 | 669 | ||
659 | return -EPERM; | 670 | return err ?: count; |
660 | } | 671 | } |
661 | 672 | ||
662 | static ssize_t rfkill_claim_show(struct device *dev, | 673 | static ssize_t rfkill_claim_show(struct device *dev, |