[PATCH] block: bio: Trim bio to sensible size in bio_trim()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
---
 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




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux