Commit 06ebb06d49486676272a3c030bfeef4bd969a8e6

Authored by Sasha Levin
Committed by David S. Miller
1 parent fcdfe3a7fa

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 <sasha.levin@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 4 additions and 0 deletions Side-by-side Diff

... ... @@ -85,6 +85,10 @@
85 85 int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
86 86 int offset, int len)
87 87 {
  88 + /* No data? Done! */
  89 + if (len == 0)
  90 + return 0;
  91 +
88 92 /* Skip over the finished iovecs */
89 93 while (offset >= iov->iov_len) {
90 94 offset -= iov->iov_len;