]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/packet: fix missing net_device reference release
authorDouglas Caetano dos Santos <douglascs@taghos.com.br>
Fri, 12 May 2017 18:19:15 +0000 (15:19 -0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 May 2017 18:22:12 +0000 (14:22 -0400)
When using a TX ring buffer, if an error occurs processing a control
message (e.g. invalid message), the net_device reference is not
released.

Fixes 1b4614be42867 ("sock: enable timestamping using control messages")
Signed-off-by: Douglas Caetano dos Santos <douglascs@taghos.com.br>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/packet/af_packet.c

index f4001763134da35ed5f0f04bc2836015bb15a4af..e3eeed19cc7a130e80e24a3d67776a5b5a3c2698 100644 (file)
@@ -2658,13 +2658,6 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
                dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
        }
 
-       sockc.tsflags = po->sk.sk_tsflags;
-       if (msg->msg_controllen) {
-               err = sock_cmsg_send(&po->sk, msg, &sockc);
-               if (unlikely(err))
-                       goto out;
-       }
-
        err = -ENXIO;
        if (unlikely(dev == NULL))
                goto out;
@@ -2672,6 +2665,13 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
        if (unlikely(!(dev->flags & IFF_UP)))
                goto out_put;
 
+       sockc.tsflags = po->sk.sk_tsflags;
+       if (msg->msg_controllen) {
+               err = sock_cmsg_send(&po->sk, msg, &sockc);
+               if (unlikely(err))
+                       goto out_put;
+       }
+
        if (po->sk.sk_socket->type == SOCK_RAW)
                reserve = dev->hard_header_len;
        size_max = po->tx_ring.frame_size