aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Howells <[email protected]>2023-05-23 13:48:41 +0100
committerSteve French <[email protected]>2023-05-23 15:35:44 -0500
commit4ef4aee67eed640064fff95a693c0184cedb7bec (patch)
treecb8f635144904b31a9d3291f60a552d43a75547a
parent44c026a73be8038f03dbdeef028b642880cf1511 (diff)
cifs: Fix cifs_limit_bvec_subset() to correctly check the maxmimum size
Fix cifs_limit_bvec_subset() so that it limits the span to the maximum specified and won't return with a size greater than max_size. Fixes: d08089f649a0 ("cifs: Change the I/O paths to use an iterator rather than a page list") Cc: [email protected] # 6.3 Reported-by: Shyam Prasad N <[email protected]> Reviewed-by: Shyam Prasad N <[email protected]> Signed-off-by: David Howells <[email protected]> cc: Steve French <[email protected]> cc: Rohith Surabattula <[email protected]> cc: Paulo Alcantara <[email protected]> cc: Tom Talpey <[email protected]> cc: Jeff Layton <[email protected]> cc: [email protected] cc: [email protected] Signed-off-by: Steve French <[email protected]>
-rw-r--r--fs/cifs/file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index ba7f2e09d6c8..df88b8c04d03 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3353,9 +3353,10 @@ static size_t cifs_limit_bvec_subset(const struct iov_iter *iter, size_t max_siz
while (n && ix < nbv) {
len = min3(n, bvecs[ix].bv_len - skip, max_size);
span += len;
+ max_size -= len;
nsegs++;
ix++;
- if (span >= max_size || nsegs >= max_segs)
+ if (max_size == 0 || nsegs >= max_segs)
break;
skip = 0;
n -= len;