File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -503,17 +503,20 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
503
503
size_t shorted = 0 ;
504
504
ssize_t ret ;
505
505
506
- if (pos >= size )
507
- return 0 ;
508
-
509
- size -= pos ;
510
- if (iov_iter_count (to ) > size ) {
511
- shorted = iov_iter_count (to ) - size ;
512
- iov_iter_truncate (to , size );
506
+ if (unlikely (pos + iov_iter_count (to ) > size )) {
507
+ if (pos >= size )
508
+ return 0 ;
509
+ size -= pos ;
510
+ if (iov_iter_count (to ) > size ) {
511
+ shorted = iov_iter_count (to ) - size ;
512
+ iov_iter_truncate (to , size );
513
+ }
513
514
}
514
515
515
516
ret = generic_file_read_iter (iocb , to );
516
- iov_iter_reexpand (to , iov_iter_count (to ) + shorted );
517
+
518
+ if (unlikely (shorted ))
519
+ iov_iter_reexpand (to , iov_iter_count (to ) + shorted );
517
520
return ret ;
518
521
}
519
522
You can’t perform that action at this time.
0 commit comments