Skip to content

Commit 4c0421f

Browse files
dhowellssmfrench
authored andcommitted
iov: Fix netfs_extract_user_to_sg()
Fix the loop check in netfs_extract_user_to_sg() for extraction from user-backed iterators to do the body if npages > 0, not if npages < 0 (which it can never be). This isn't currently used by cifs, which only ever extracts data from BVEC, KVEC and XARRAY iterators at this level, user-backed iterators having being decanted into BVEC iterators at a higher level to accommodate the work being done in a kernel thread. Found by smatch: fs/netfs/iterator.c:139 netfs_extract_user_to_sg() warn: unsigned 'npages' is never less than zero. Fixes: 0185846 ("netfs: Add a function to extract an iterator into a scatterlist") Reported-by: kernel test robot <[email protected]> Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Reported-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/Y/yYnAhoAYDBKixX@kili Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: David Howells <[email protected]> cc: Jeff Layton <[email protected]> cc: [email protected] cc: [email protected] Signed-off-by: Steve French <[email protected]>
1 parent 0268792 commit 4c0421f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/netfs/iterator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static ssize_t netfs_extract_user_to_sg(struct iov_iter *iter,
134134
npages = DIV_ROUND_UP(off + len, PAGE_SIZE);
135135
sg_max -= npages;
136136

137-
for (; npages < 0; npages--) {
137+
for (; npages > 0; npages--) {
138138
struct page *page = *pages;
139139
size_t seg = min_t(size_t, PAGE_SIZE - off, len);
140140

0 commit comments

Comments
 (0)