From: Miaohe Lin <linmiaohe@huawei.com>
To: <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linmiaohe@huawei.com>
Subject: [PATCH] block: bio: Trim bio to sensible size in bio_trim()
Date: Sat, 29 Aug 2020 05:37:33 -0400 [thread overview]
Message-ID: <20200829093733.45833-1-linmiaohe@huawei.com> (raw)
Trim bio to sensible size in bio_trim() or something bad may happen.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
block/bio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/bio.c b/block/bio.c
index a9931f23d933..94e4f97d3d4e 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1509,7 +1509,8 @@ void bio_trim(struct bio *bio, int offset, int size)
return;
bio_advance(bio, offset << 9);
- bio->bi_iter.bi_size = size;
+ if (likely(bio->bi_iter.bi_size >= size))
+ bio->bi_iter.bi_size = size;
if (bio_integrity(bio))
bio_integrity_trim(bio);
--
2.19.1
next reply other threads:[~2020-08-29 9:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-29 9:37 Miaohe Lin [this message]
2020-08-29 14:32 ` [PATCH] block: bio: Trim bio to sensible size in bio_trim() Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2020-08-31 6:26 linmiaohe
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=20200829093733.45833-1-linmiaohe@huawei.com \
--to=linmiaohe@huawei.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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