From: Joel Fernandes <[email protected]>

Updating "ppos" on error conditions does not make much sense. The pattern
is to return the error code directly without modifying the position, or
modify the position on success and return the number of bytes written.

Since on success, the return value of apply is 0, there is no point in
modifying ppos either. Fix it by removing all this and just returning
error code or number of bytes written on success.

Tested-by: Christian Loehle <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Reviewed-by: Juri Lelli <[email protected]>
Reviewed-by: Andrea Righi <[email protected]>
Signed-off-by: Joel Fernandes <[email protected]>
---
 kernel/sched/debug.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 41caa22e0680a..93f009e1076d8 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -345,8 +345,8 @@ static ssize_t sched_fair_server_write(struct file *filp, 
const char __user *ubu
        long cpu = (long) ((struct seq_file *) filp->private_data)->private;
        struct rq *rq = cpu_rq(cpu);
        u64 runtime, period;
+       int retval = 0;
        size_t err;
-       int retval;
        u64 value;
 
        err = kstrtoull_from_user(ubuf, cnt, 10, &value);
@@ -380,8 +380,6 @@ static ssize_t sched_fair_server_write(struct file *filp, 
const char __user *ubu
                dl_server_stop(&rq->fair_server);
 
                retval = dl_server_apply_params(&rq->fair_server, runtime, 
period, 0);
-               if (retval)
-                       cnt = retval;
 
                if (!runtime)
                        printk_deferred("Fair server disabled in CPU %d, system 
may crash due to starvation.\n",
@@ -389,6 +387,9 @@ static ssize_t sched_fair_server_write(struct file *filp, 
const char __user *ubu
 
                if (rq->cfs.h_nr_queued)
                        dl_server_start(&rq->fair_server);
+
+               if (retval < 0)
+                       return retval;
        }
 
        *ppos += cnt;
-- 
2.52.0


Reply via email to