Skip to content

Commit

Permalink
block: fix error in handling dead task for ioprio setting
Browse files Browse the repository at this point in the history
Don't combine the task exiting and "already have io_context" case, we
need to just abort if the task is marked as dead. Return -ESRCH, which
is the documented value for ioprio_set() if the specified task could not
be found.

Reported-by: Dan Carpenter <[email protected]>
Reported-by: [email protected]
Fixes: 5fc11ee ("block: open code create_task_io_context in set_task_ioprio")
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Dec 21, 2021
1 parent 518579a commit a957b61
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions block/blk-ioc.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,22 @@ int set_task_ioprio(struct task_struct *task, int ioprio)
return -ENOMEM;

task_lock(task);
if (task->io_context || (task->flags & PF_EXITING)) {
if (task->flags & PF_EXITING) {
err = -ESRCH;
kmem_cache_free(iocontext_cachep, ioc);
goto out;
}
if (task->io_context) {
kmem_cache_free(iocontext_cachep, ioc);
ioc = task->io_context;
} else {
task->io_context = ioc;
}
}
task->io_context->ioprio = ioprio;
out:
task_unlock(task);
return 0;
return err;
}
EXPORT_SYMBOL_GPL(set_task_ioprio);

Expand Down

0 comments on commit a957b61

Please sign in to comment.