All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] io_uring: Fix error returns when create_io_thread fails
@ 2021-03-05  9:32 Colin King
  2021-03-05 14:11 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-03-05  9:32 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov, io-uring; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The error return when create_io_thread calls fail is not using the
error return code from the returned pointer. Fix this by using
the error code in PTR_ERR(tsk).

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: c3c9a3194bd0 ("io_uring: move to using create_io_thread()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/io_uring.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index b52ef6df4aac..59b024dba4dc 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7787,7 +7787,7 @@ static int io_sq_thread_fork(struct io_sq_data *sqd, struct io_ring_ctx *ctx)
 	sqd->task_pid = current->pid;
 	tsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE);
 	if (IS_ERR(tsk))
-		return ret;
+		return PTR_ERR(tsk);
 	ret = io_uring_alloc_task_context(tsk, ctx);
 	if (ret)
 		set_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
@@ -7859,8 +7859,10 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
 
 		sqd->task_pid = current->pid;
 		tsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE);
-		if (IS_ERR(tsk))
+		if (IS_ERR(tsk)) {
+			ret = PTR_ERR(tsk);
 			goto err;
+		}
 		ret = io_uring_alloc_task_context(tsk, ctx);
 		if (ret)
 			set_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] io_uring: Fix error returns when create_io_thread fails
  2021-03-05  9:32 [PATCH][next] io_uring: Fix error returns when create_io_thread fails Colin King
@ 2021-03-05 14:11 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-03-05 14:11 UTC (permalink / raw)
  To: Colin King, Pavel Begunkov, io-uring; +Cc: kernel-janitors, linux-kernel

On 3/5/21 2:32 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The error return when create_io_thread calls fail is not using the
> error return code from the returned pointer. Fix this by using
> the error code in PTR_ERR(tsk).

Thanks Colin, I'm going to fold this in.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-05 14:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05  9:32 [PATCH][next] io_uring: Fix error returns when create_io_thread fails Colin King
2021-03-05 14:11 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.