sctp: remove the unessessary hold for idev in sctp_v6_err
authorXin Long <lucien.xin@gmail.com>
Tue, 22 Jun 2021 18:04:57 +0000 (14:04 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 22 Jun 2021 18:28:52 +0000 (11:28 -0700)
Same as in tcp_v6_err() and __udp6_lib_err(), there's no need to
hold idev in sctp_v6_err(), so just call __in6_dev_get() instead.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/ipv6.c

index bd08807..50ed4de 100644 (file)
@@ -126,7 +126,6 @@ static struct notifier_block sctp_inet6addr_notifier = {
 static int sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                        u8 type, u8 code, int offset, __be32 info)
 {
-       struct inet6_dev *idev;
        struct sock *sk;
        struct sctp_association *asoc;
        struct sctp_transport *transport;
@@ -135,8 +134,6 @@ static int sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        int err, ret = 0;
        struct net *net = dev_net(skb->dev);
 
-       idev = in6_dev_get(skb->dev);
-
        /* Fix up skb to look at the embedded net header. */
        saveip   = skb->network_header;
        savesctp = skb->transport_header;
@@ -147,9 +144,8 @@ static int sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        skb->network_header   = saveip;
        skb->transport_header = savesctp;
        if (!sk) {
-               __ICMP6_INC_STATS(net, idev, ICMP6_MIB_INERRORS);
-               ret = -ENOENT;
-               goto out;
+               __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev), ICMP6_MIB_INERRORS);
+               return -ENOENT;
        }
 
        /* Warning:  The sock lock is held.  Remember to call
@@ -185,10 +181,6 @@ static int sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 
 out_unlock:
        sctp_err_finish(sk, transport);
-out:
-       if (likely(idev != NULL))
-               in6_dev_put(idev);
-
        return ret;
 }