diff mbox

[net-next,2/3] net: Fix memcpy_toiovecend() to use the right offset

Message ID 1244230544.1526.77.camel@w-sridhar.beaverton.ibm.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Sridhar Samudrala June 5, 2009, 7:35 p.m. UTC
Increment the iovec base by the offset passed in for the initial
copy_to_user() in memcpy_to_iovecend().

Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>





--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Michael S. Tsirkin June 6, 2009, 9:13 p.m. UTC | #1
On Fri, Jun 05, 2009 at 12:35:44PM -0700, Sridhar Samudrala wrote:
> Increment the iovec base by the offset passed in for the initial
> copy_to_user() in memcpy_to_iovecend().
> 
> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> diff --git a/net/core/iovec.c b/net/core/iovec.c
> index 40a76ce..16ad45d 100644
> --- a/net/core/iovec.c
> +++ b/net/core/iovec.c
> @@ -112,9 +112,9 @@ int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
>  			continue;
>  		}
>  		copy = min_t(unsigned int, iov->iov_len - offset, len);
> -		offset = 0;
> -		if (copy_to_user(iov->iov_base, kdata, copy))
> +		if (copy_to_user(iov->iov_base + offset, kdata, copy))
>  			return -EFAULT;
> +		offset = 0;
>  		kdata += copy;
>  		len -= copy;
>  	}
> 
> 
>
David Miller June 8, 2009, 7:28 a.m. UTC | #2
From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Sun, 7 Jun 2009 00:13:21 +0300

> On Fri, Jun 05, 2009 at 12:35:44PM -0700, Sridhar Samudrala wrote:
>> Increment the iovec base by the offset passed in for the initial
>> copy_to_user() in memcpy_to_iovecend().
>> 
>> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
> 
> Acked-by: Michael S. Tsirkin <mst@redhat.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/iovec.c b/net/core/iovec.c
index 40a76ce..16ad45d 100644
--- a/net/core/iovec.c
+++ b/net/core/iovec.c
@@ -112,9 +112,9 @@  int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
 			continue;
 		}
 		copy = min_t(unsigned int, iov->iov_len - offset, len);
-		offset = 0;
-		if (copy_to_user(iov->iov_base, kdata, copy))
+		if (copy_to_user(iov->iov_base + offset, kdata, copy))
 			return -EFAULT;
+		offset = 0;
 		kdata += copy;
 		len -= copy;
 	}