2015-02-26 22:57:07

by Luis Henriques

[permalink] [raw]
Subject: [PATCH] block: ioprio: fix error path return code in set_task_ioprio()

set_task_ioprio() could return success (zero) even if it actually failed
to set the new ioprio. This patch fixes this by returning -ENOMEM if the
call to get_task_io_context() fails.

Signed-off-by: Luis Henriques <[email protected]>
---
block/ioprio.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/ioprio.c b/block/ioprio.c
index 31666c92b46a..42c680a17be4 100644
--- a/block/ioprio.c
+++ b/block/ioprio.c
@@ -49,12 +49,12 @@ int set_task_ioprio(struct task_struct *task, int ioprio)
return err;

ioc = get_task_io_context(task, GFP_ATOMIC, NUMA_NO_NODE);
- if (ioc) {
- ioc->ioprio = ioprio;
- put_io_context(ioc);
- }
+ if (!ioc)
+ return -ENOMEM;
+ ioc->ioprio = ioprio;
+ put_io_context(ioc);

- return err;
+ return 0;
}
EXPORT_SYMBOL_GPL(set_task_ioprio);

--
2.1.4