]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - block/ioprio.c
bdi: Fix another oops in wb_workfn()
[linux.git] / block / ioprio.c
index 6f5d0b6625e39b930d93aca15082daec481f0199..f9821080c92ccbc242ef9d2f819d06588c3d7fe9 100644 (file)
@@ -61,15 +61,10 @@ int set_task_ioprio(struct task_struct *task, int ioprio)
 }
 EXPORT_SYMBOL_GPL(set_task_ioprio);
 
-SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
+int ioprio_check_cap(int ioprio)
 {
        int class = IOPRIO_PRIO_CLASS(ioprio);
        int data = IOPRIO_PRIO_DATA(ioprio);
-       struct task_struct *p, *g;
-       struct user_struct *user;
-       struct pid *pgrp;
-       kuid_t uid;
-       int ret;
 
        switch (class) {
                case IOPRIO_CLASS_RT:
@@ -92,6 +87,21 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
                        return -EINVAL;
        }
 
+       return 0;
+}
+
+SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
+{
+       struct task_struct *p, *g;
+       struct user_struct *user;
+       struct pid *pgrp;
+       kuid_t uid;
+       int ret;
+
+       ret = ioprio_check_cap(ioprio);
+       if (ret)
+               return ret;
+
        ret = -ESRCH;
        rcu_read_lock();
        switch (which) {