xfrm6: release dev before returning error
authorCong Wang <amwang@redhat.com>
Thu, 9 May 2013 22:40:00 +0000 (22:40 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 30 May 2013 13:35:14 +0000 (14:35 +0100)
[ Upstream commit 84c4a9dfbf430861e7588d95ae3ff61535dca351 ]

We forget to call dev_put() on error path in xfrm6_fill_dst(),
its caller doesn't handle this.

Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/ipv6/xfrm6_policy.c

index d879f7e..db78e7d 100644 (file)
@@ -96,8 +96,10 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
        dev_hold(dev);
 
        xdst->u.rt6.rt6i_idev = in6_dev_get(dev);
-       if (!xdst->u.rt6.rt6i_idev)
+       if (!xdst->u.rt6.rt6i_idev) {
+               dev_put(dev);
                return -ENODEV;
+       }
 
        xdst->u.rt6.rt6i_peer = rt->rt6i_peer;
        if (rt->rt6i_peer)