[TUN]: Fix leak in tun_get_user()
Changes
1 files changed · +4 −1
| File | Status | Add | Del | Content |
|---|---|---|---|---|
| drivers/net/tun.c | modified | +4 | −1 | View file |
drivers/net/tun.c
View filediff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 50b8c67..a1ed2d9 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -249,8 +249,11 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv,
if (align)
skb_reserve(skb, align);
- if (memcpy_fromiovec(skb_put(skb, len), iv, len))
+ if (memcpy_fromiovec(skb_put(skb, len), iv, len)) {
+ tun->stats.rx_dropped++;
+ kfree_skb(skb);
return -EFAULT;
+ }
skb->dev = tun->dev;
switch (tun->flags & TUN_TYPE_MASK) {