diff mbox

[net-next] tun: return proper error code from tun_do_read

Message ID 1419578569-13132-1-git-send-email-agartrell@fb.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Alex Gartrell Dec. 26, 2014, 7:22 a.m. UTC
Instead of -1 with EAGAIN, read on a O_NONBLOCK tun fd will return 0.  This
fixes this by properly returning the error code from __skb_recv_datagram.

Signed-off-by: Alex Gartrell <agartrell@fb.com>
---
 drivers/net/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller Dec. 31, 2014, 7:15 p.m. UTC | #1
From: Alex Gartrell <agartrell@fb.com>
Date: Thu, 25 Dec 2014 23:22:49 -0800

> Instead of -1 with EAGAIN, read on a O_NONBLOCK tun fd will return 0.  This
> fixes this by properly returning the error code from __skb_recv_datagram.
> 
> Signed-off-by: Alex Gartrell <agartrell@fb.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/drivers/net/tun.c b/drivers/net/tun.c
index a5cbf67..2f65d6c 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1378,7 +1378,7 @@  static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
 	skb = __skb_recv_datagram(tfile->socket.sk, noblock ? MSG_DONTWAIT : 0,
 				  &peeked, &off, &err);
 	if (!skb)
-		return 0;
+		return err;
 
 	ret = tun_put_user(tun, tfile, skb, to);
 	if (unlikely(ret < 0))