Skip to content

Commit 6a30653

Browse files
dhowellskuba-moo
authored andcommitted
Fix a potential infinite loop in extract_user_to_sg()
Fix extract_user_to_sg() so that it will break out of the loop if iov_iter_extract_pages() returns 0 rather than looping around forever. [Note that I've included two fixes lines as the function got moved to a different file and renamed] Fixes: 85dd2c8 ("netfs: Add a function to extract a UBUF or IOVEC into a BVEC iterator") Fixes: f5f82cd ("Move netfs_extract_iter_to_sg() to lib/scatterlist.c") Signed-off-by: David Howells <[email protected]> cc: Jeff Layton <[email protected]> cc: Steve French <[email protected]> cc: Herbert Xu <[email protected]> cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 42f853b commit 6a30653

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/scatterlist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ static ssize_t extract_user_to_sg(struct iov_iter *iter,
11241124
do {
11251125
res = iov_iter_extract_pages(iter, &pages, maxsize, sg_max,
11261126
extraction_flags, &off);
1127-
if (res < 0)
1127+
if (res <= 0)
11281128
goto failed;
11291129

11301130
len = res;

0 commit comments

Comments
 (0)