public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jiapeng Chong <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
	[email protected],
	Jiapeng Chong <[email protected]>,
	Abaci Robot <[email protected]>
Subject: [PATCH] io_uring: rw: Fix an unsigned comparison which can never be negative
Date: Thu, 15 Sep 2022 13:49:09 +0800	[thread overview]
Message-ID: <[email protected]> (raw)

The parameter 'res' is defined as unsigned type, so the following if
statement is invalid, we can modify the type of res to long.
if (res < 0)
  	res = io->bytes_done;
else
  	res += io->bytes_done;

io_uring/rw.c:265 io_fixup_rw_res() warn: unsigned 'res' is never less than zero.

Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2184
Reported-by: Abaci Robot <[email protected]>
Signed-off-by: Jiapeng Chong <[email protected]>
---
 io_uring/rw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/io_uring/rw.c b/io_uring/rw.c
index b777c35378b9..08d88481153c 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -256,7 +256,7 @@ static bool __io_complete_rw_common(struct io_kiocb *req, long res)
 	return false;
 }
 
-static inline unsigned io_fixup_rw_res(struct io_kiocb *req, unsigned res)
+static inline unsigned io_fixup_rw_res(struct io_kiocb *req, long res)
 {
 	struct io_async_rw *io = req->async_data;
 
-- 
2.20.1.7.g153144c


             reply	other threads:[~2022-09-15  5:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  5:49 Jiapeng Chong [this message]
2022-09-15  6:27 ` [PATCH] io_uring: rw: Fix an unsigned comparison which can never be negative Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220915054909.81394-1-jiapeng.chong@linux.alibaba.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox