Thread (10 messages) 10 messages, 3 authors, 2017-12-04

Re: [PATCH 3/3] tap: free skb if flags error

flat view

From: Jason Wang <hidden>
Date: 2017-12-01 07:10:18
Also in: lkml


On 2017年12月01日 13:54, wexu@redhat.com wrote:
quoted hunk ↗ jump to hunk
From: Wei Xu <redacted>

tap_recvmsg() supports accepting skb by msg_control after
commit 3b4ba04acca8 ("tap: support receiving skb from msg_control"),
the skb if presented should be freed within the function, otherwise
it would be leaked.

Signed-off-by: Wei Xu <redacted>
Reported-by: Matthew Rosato <redacted>
---
  drivers/net/tap.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index e9489b8..1c66b75 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -1154,9 +1154,13 @@ static int tap_recvmsg(struct socket *sock, struct msghdr *m,
  		       size_t total_len, int flags)
  {
  	struct tap_queue *q = container_of(sock, struct tap_queue, sock);
+	struct sk_buff *skb = m->msg_control;
  	int ret;
-	if (flags & ~(MSG_DONTWAIT|MSG_TRUNC))
+	if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) {
+		if (skb)
+			kfree_skb(skb);
  		return -EINVAL;
+	}
  	ret = tap_do_read(q, &m->msg_iter, flags & MSG_DONTWAIT,
  			  m->msg_control);
Need to deal with iov_iterator_count() == 0.

Thanks
  	if (ret > total_len) {
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help