Skip to content

Commit 06ebb06

Browse files
sashalevindavem330
authored andcommitted
iovec: make sure the caller actually wants anything in memcpy_fromiovecend
Check for cases when the caller requests 0 bytes instead of running off and dereferencing potentially invalid iovecs. Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fcdfe3a commit 06ebb06

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/iovec.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ EXPORT_SYMBOL(memcpy_toiovecend);
8585
int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
8686
int offset, int len)
8787
{
88+
/* No data? Done! */
89+
if (len == 0)
90+
return 0;
91+
8892
/* Skip over the finished iovecs */
8993
while (offset >= iov->iov_len) {
9094
offset -= iov->iov_len;

0 commit comments

Comments
 (0)