Skip to content

Commit

Permalink
block: fix offset/size check in bio_trim()
Browse files Browse the repository at this point in the history
Unit of bio->bi_iter.bi_size is bytes, but unit of offset/size
is sector.

Fix the above issue in checking offset/size in bio_trim().

Fixes: e83502c ("block: fix argument type of bio_trim()")
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20220414084443.1736850-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Ming Lei authored and axboe committed Apr 14, 2022
1 parent b976875 commit 8535c01
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ EXPORT_SYMBOL(bio_split);
void bio_trim(struct bio *bio, sector_t offset, sector_t size)
{
if (WARN_ON_ONCE(offset > BIO_MAX_SECTORS || size > BIO_MAX_SECTORS ||
offset + size > bio->bi_iter.bi_size))
offset + size > bio_sectors(bio)))
return;

size <<= 9;
Expand Down

0 comments on commit 8535c01

Please sign in to comment.