netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] tun: handle copy failure in tun_put_user()
@ 2014-01-20  3:16 Jason Wang
  2014-01-20  3:48 ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Jason Wang @ 2014-01-20  3:16 UTC (permalink / raw)
  To: davem, netdev, linux-kernel; +Cc: Jason Wang, Michael S. Tsirkin

This patch return the error code of copy helpers in tun_put_user() instead of
ignoring them.

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/net/tun.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index ecec802..4ec8f28 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1185,7 +1185,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 {
 	struct tun_pi pi = { 0, skb->protocol };
 	ssize_t total = 0;
-	int vlan_offset = 0, copied;
+	int vlan_offset = 0, copied, ret;
 
 	if (!(tun->flags & TUN_NO_PI)) {
 		if ((len -= sizeof(pi)) < 0)
@@ -1254,7 +1254,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 	if (!vlan_tx_tag_present(skb)) {
 		len = min_t(int, skb->len, len);
 	} else {
-		int copy, ret;
+		int copy;
 		struct {
 			__be16 h_vlan_proto;
 			__be16 h_vlan_TCI;
@@ -1282,13 +1282,13 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 			goto done;
 	}
 
-	skb_copy_datagram_const_iovec(skb, vlan_offset, iv, copied, len);
+	ret = skb_copy_datagram_const_iovec(skb, vlan_offset, iv, copied, len);
 
 done:
 	tun->dev->stats.tx_packets++;
 	tun->dev->stats.tx_bytes += len;
 
-	return total;
+	return ret ? ret : total;
 }
 
 static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-01-20  9:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-20  3:16 [PATCH net] tun: handle copy failure in tun_put_user() Jason Wang
2014-01-20  3:48 ` David Miller
2014-01-20  5:02   ` Jason Wang
     [not found]   ` <20140119.194856.491294439635992592.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2014-01-20  8:43     ` Michael S. Tsirkin
2014-01-20  9:32       ` Jason Wang
     [not found]         ` <52DCED12.501-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-20  9:52           ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).