Re: [PATCH net-next 06/13] ipv6: Create cleanup helper for fib6_nh
From: Ido Schimmel <hidden>
Date: 2019-03-27 08:38:59
On Tue, Mar 26, 2019 at 08:29:35PM -0700, David Ahern wrote:
quoted hunk ↗ jump to hunk
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 6613d8dbb0e5..db886085369b 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c@@ -199,10 +199,7 @@ void fib6_info_destroy_rcu(struct rcu_head *head) free_percpu(f6i->rt6i_pcpu); } - lwtstate_put(f6i->fib6_nh.nh_lwtstate); - - if (f6i->fib6_nh.nh_dev) - dev_put(f6i->fib6_nh.nh_dev); + fib6_nh_release(&f6i->fib6_nh); ip_fib_metrics_put(f6i->fib6_metrics);diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 269ad7b9cdbb..4923a5f88e9b 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c@@ -3012,6 +3012,14 @@ int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh, return err; } +void fib6_nh_release(struct fib6_nh *fib6_nh) +{ + if (fib6_nh->nh_dev) + dev_put(fib6_nh->nh_dev); + + lwtstate_put(fib6_nh->nh_lwtstate);
Why did you flip the order? lwtstate_put() dev_put() is symmetric with fib6_nh_init()
+}