Skip to contentSkip to conversation

tun: return proper error code from tun_do_read

PATCH Applied Alex Gartrell 2 participants 2 messages Dec 26, 2014 – Dec 31, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tun: return proper error code from tun_do_read

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.

---
 drivers/net/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/tun.c +1 -1
index a5cbf67..2f65d6c 100644
@@ -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))
Signature · 1 line
Alex Gartrell <[email protected]>