Skip to content

Commit f4b7826

Browse files
isilenceakpm00
authored andcommitted
lib/iov_iter: fix import_iovec_ubuf iovec management
import_iovec() says that it should always be fine to kfree the iovec returned in @iovp regardless of the error code. __import_iovec_ubuf() never reallocates it and thus should clear the pointer even in cases when copy_iovec_*() fail. Link: https://lkml.kernel.org/r/378ae26923ffc20fd5e41b4360d673bf47b1775b.1738332461.git.asml.silence@gmail.com Fixes: 3b2deb0 ("iov_iter: import single vector iovecs as ITER_UBUF") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Jens Axboe <axboe@kernel.dk> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christian Brauner <brauner@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent c8a3e63 commit f4b7826

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/iov_iter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,8 @@ static ssize_t __import_iovec_ubuf(int type, const struct iovec __user *uvec,
14281428
struct iovec *iov = *iovp;
14291429
ssize_t ret;
14301430

1431+
*iovp = NULL;
1432+
14311433
if (compat)
14321434
ret = copy_compat_iovec_from_user(iov, uvec, 1);
14331435
else
@@ -1438,7 +1440,6 @@ static ssize_t __import_iovec_ubuf(int type, const struct iovec __user *uvec,
14381440
ret = import_ubuf(type, iov->iov_base, iov->iov_len, i);
14391441
if (unlikely(ret))
14401442
return ret;
1441-
*iovp = NULL;
14421443
return i->count;
14431444
}
14441445

0 commit comments

Comments
 (0)