Skip to content

Commit 3811ae7

Browse files
Gao fengdavem330
authored andcommitted
net: tun: release the reference of tun device in tun_recvmsg
We forget to release the reference of tun device in tun_recvmsg. bug introduced in commit 54f968d (tuntap: move socket to tun_file) Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b9e48de commit 3811ae7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/net/tun.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,14 +1471,17 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
14711471
if (!tun)
14721472
return -EBADFD;
14731473

1474-
if (flags & ~(MSG_DONTWAIT|MSG_TRUNC))
1475-
return -EINVAL;
1474+
if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) {
1475+
ret = -EINVAL;
1476+
goto out;
1477+
}
14761478
ret = tun_do_read(tun, tfile, iocb, m->msg_iov, total_len,
14771479
flags & MSG_DONTWAIT);
14781480
if (ret > total_len) {
14791481
m->msg_flags |= MSG_TRUNC;
14801482
ret = flags & MSG_TRUNC ? ret : total_len;
14811483
}
1484+
out:
14821485
tun_put(tun);
14831486
return ret;
14841487
}

0 commit comments

Comments
 (0)