Skip to content

Commit 91215f7

Browse files
Su Huiaxboe
authored andcommitted
io_uring/io-wq: avoid garbage value of 'match' in io_wq_enqueue()
Clang static checker (scan-build) warning: o_uring/io-wq.c:line 1051, column 3 The expression is an uninitialized value. The computed value will also be garbage. 'match.nr_pending' is used in io_acct_cancel_pending_work(), but it is not fully initialized. Change the order of assignment for 'match' to fix this problem. Fixes: 42abc95 ("io-wq: decouple work_list protection from the big wqe->lock") Signed-off-by: Su Hui <suhui@nfschina.com> Link: https://lore.kernel.org/r/20240604121242.2661244-1-suhui@nfschina.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 415ce0e commit 91215f7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

io_uring/io-wq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,11 @@ void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work)
927927
{
928928
struct io_wq_acct *acct = io_work_get_acct(wq, work);
929929
unsigned long work_flags = work->flags;
930-
struct io_cb_cancel_data match;
930+
struct io_cb_cancel_data match = {
931+
.fn = io_wq_work_match_item,
932+
.data = work,
933+
.cancel_all = false,
934+
};
931935
bool do_create;
932936

933937
/*
@@ -965,10 +969,6 @@ void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work)
965969
raw_spin_unlock(&wq->lock);
966970

967971
/* fatal condition, failed to create the first worker */
968-
match.fn = io_wq_work_match_item,
969-
match.data = work,
970-
match.cancel_all = false,
971-
972972
io_acct_cancel_pending_work(wq, acct, &match);
973973
}
974974
}

0 commit comments

Comments
 (0)