Transfer the skb_pool_flush() function from netpoll to netconsole, and call it within netpoll_cleanup() to ensure skb pool resources are properly released once the device is down. The invocation of skb_pool_flush() was removed from netpoll_setup(), as the pool is now only managed after successful allocation. This complete the move of skb pool management from netpoll to netconsole. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 10 ++++++++++ net/core/netpoll.c | 15 +-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index bf7bab7a9c2f0..b9bfb78560b3c 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -300,12 +300,22 @@ static struct netconsole_target *alloc_and_init(void) return nt; } +static void skb_pool_flush(struct netpoll *np) +{ + struct sk_buff_head *skb_pool; + + cancel_work_sync(&np->refill_wq); + skb_pool = &np->skb_pool; + skb_queue_purge_reason(skb_pool, SKB_CONSUMED); +} + static void netpoll_cleanup(struct netpoll *np) { rtnl_lock(); if (!np->dev) goto out; do_netpoll_cleanup(np); + skb_pool_flush(np); out: rtnl_unlock(); } diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 5aa83c9c09e05..c0eeeb9ac3daf 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -326,15 +326,6 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) } EXPORT_SYMBOL(netpoll_send_skb); -static void skb_pool_flush(struct netpoll *np) -{ - struct sk_buff_head *skb_pool; - - cancel_work_sync(&np->refill_wq); - skb_pool = &np->skb_pool; - skb_queue_purge_reason(skb_pool, SKB_CONSUMED); -} - int __netpoll_setup(struct netpoll *np, struct net_device *ndev) { struct netpoll_info *npinfo; @@ -547,7 +538,7 @@ int netpoll_setup(struct netpoll *np) err = __netpoll_setup(np, ndev); if (err) - goto flush; + goto put; rtnl_unlock(); /* Make sure all NAPI polls which started before dev->npinfo @@ -558,8 +549,6 @@ int netpoll_setup(struct netpoll *np) return 0; -flush: - skb_pool_flush(np); put: DEBUG_NET_WARN_ON_ONCE(np->dev); if (ip_overwritten) @@ -607,8 +596,6 @@ static void __netpoll_cleanup(struct netpoll *np) call_rcu(&npinfo->rcu, rcu_cleanup_netpoll_info); } else RCU_INIT_POINTER(np->dev->npinfo, NULL); - - skb_pool_flush(np); } void __netpoll_free(struct netpoll *np) -- 2.47.3