Skip to contentSkip to conversation

block: bio: Trim bio to sensible size in bio_trim()

PATCH In review Miaohe Lin 2 participants 2 messages Aug 29, 2020 Block layer

lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 1/1 block: bio: Trim bio to sensible size in bio_trim()

Trim bio to sensible size in bio_trim() or something bad may happen.

---
 block/bio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/bio.c +2 -1
index a9931f23d933..94e4f97d3d4e 100644
@@ -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);
Signature · 1 line
2.19.1
maintainer
#1 lore raw
Quoted 1 line · Miaohe Lin

Trim bio to sensible size in bio_trim() or something bad may happen.

This really needs a LOT more detail. What is "something bad"? How does this condition trigger to begin with?

Signature · 1 line
Jens Axboe