]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - kernel/power/wakelock.c
PM / Sleep: Require CAP_BLOCK_SUSPEND to use wake_lock/wake_unlock
[karo-tx-linux.git] / kernel / power / wakelock.c
index c8fba3380076afd8db340855340e5886b8497dc6..8f50de394d22b30090d1cf62cd3fd3069d451d57 100644 (file)
@@ -9,6 +9,7 @@
  * manipulate wakelocks on Android.
  */
 
+#include <linux/capability.h>
 #include <linux/ctype.h>
 #include <linux/device.h>
 #include <linux/err.h>
@@ -188,6 +189,9 @@ int pm_wake_lock(const char *buf)
        size_t len;
        int ret = 0;
 
+       if (!capable(CAP_BLOCK_SUSPEND))
+               return -EPERM;
+
        while (*str && !isspace(*str))
                str++;
 
@@ -231,6 +235,9 @@ int pm_wake_unlock(const char *buf)
        size_t len;
        int ret = 0;
 
+       if (!capable(CAP_BLOCK_SUSPEND))
+               return -EPERM;
+
        len = strlen(buf);
        if (!len)
                return -EINVAL;