* [PATCH] io_uring/io-wq: avoid garbge value of 'match' in io_wq_enqueue()
@ 2024-06-04 12:12 Su Hui
2024-06-04 13:38 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Su Hui @ 2024-06-04 12:12 UTC (permalink / raw)
To: axboe, asml.silence, nathan, ndesaulniers, morbo, justinstitt
Cc: Su Hui, haoxu, io-uring, linux-kernel, llvm, kernel-janitors
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 initialized. Change the order of assignment for 'match' to fix
this problem.
Fixes: 42abc95f05bf ("io-wq: decouple work_list protection from the big wqe->lock")
Signed-off-by: Su Hui <[email protected]>
---
io_uring/io-wq.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
index d1c47a9d9215..7d3316fe9bfc 100644
--- a/io_uring/io-wq.c
+++ b/io_uring/io-wq.c
@@ -927,7 +927,11 @@ void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work)
{
struct io_wq_acct *acct = io_work_get_acct(wq, work);
unsigned long work_flags = work->flags;
- struct io_cb_cancel_data match;
+ struct io_cb_cancel_data match = {
+ .fn = io_wq_work_match_item,
+ .data = work,
+ .cancel_all = false,
+ };
bool do_create;
/*
@@ -965,10 +969,6 @@ void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work)
raw_spin_unlock(&wq->lock);
/* fatal condition, failed to create the first worker */
- match.fn = io_wq_work_match_item,
- match.data = work,
- match.cancel_all = false,
-
io_acct_cancel_pending_work(wq, acct, &match);
}
}
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] io_uring/io-wq: avoid garbge value of 'match' in io_wq_enqueue()
2024-06-04 12:12 [PATCH] io_uring/io-wq: avoid garbge value of 'match' in io_wq_enqueue() Su Hui
@ 2024-06-04 13:38 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2024-06-04 13:38 UTC (permalink / raw)
To: asml.silence, nathan, ndesaulniers, morbo, justinstitt, Su Hui
Cc: haoxu, io-uring, linux-kernel, llvm, kernel-janitors
On Tue, 04 Jun 2024 20:12:43 +0800, Su Hui wrote:
> 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 initialized. Change the order of assignment for 'match' to fix
> this problem.
>
> [...]
Applied, thanks!
[1/1] io_uring/io-wq: avoid garbge value of 'match' in io_wq_enqueue()
commit: e87863ed45a1c36b0d8a5b70134caf8c794d8d57
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-04 13:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04 12:12 [PATCH] io_uring/io-wq: avoid garbge value of 'match' in io_wq_enqueue() Su Hui
2024-06-04 13:38 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox