]> git.hungrycats.org Git - linux/commitdiff
tun: return proper error code from tun_do_read
authorAlex Gartrell <agartrell@fb.com>
Fri, 26 Dec 2014 07:22:49 +0000 (23:22 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Apr 2015 08:23:41 +0000 (10:23 +0200)
[ Upstream commit 957f094f221f81e457133b1f4c4d95ffa49ff731 ]

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/tun.c

index 10f9e4021b5ab9799c2e445fa1f6f9c4799293b3..9a409a8f3b19fdd10e28c6eae3ebaf2ff7bc5476 100644 (file)
@@ -1368,7 +1368,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))