From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arjun Vynipadath Subject: [PATCH net-next] cxgb4vf: fix memleak in mac_hlist initialization Date: Fri, 9 Nov 2018 14:52:01 +0530 Message-ID: <20181109092201.17546-1-arjun@chelsio.com> Cc: nirranjan@chelsio.com, indranil@chelsio.com, dt@chelsio.com, Arjun Vynipadath , Ganesh Goudar To: netdev@vger.kernel.org, davem@davemloft.net Return-path: Received: from stargate.chelsio.com ([12.32.117.8]:47831 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbeKITBx (ORCPT ); Fri, 9 Nov 2018 14:01:53 -0500 Sender: netdev-owner@vger.kernel.org List-ID: mac_hlist was initialized during adapter_up, which will be called every time a vf device is first brought up, or every time when device is brought up again after bringing all devices down. This means our state of previous list is lost, causing a memleak if entries are present in the list. To fix that, move list init to the condition that performs initial one time adapter setup. Signed-off-by: Arjun Vynipadath Signed-off-by: Ganesh Goudar --- drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index ff84791..972dc7b 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c @@ -722,6 +722,10 @@ static int adapter_up(struct adapter *adapter) if (adapter->flags & USING_MSIX) name_msix_vecs(adapter); + + /* Initialize hash mac addr list*/ + INIT_LIST_HEAD(&adapter->mac_hlist); + adapter->flags |= FULL_INIT_DONE; } @@ -747,8 +751,6 @@ static int adapter_up(struct adapter *adapter) enable_rx(adapter); t4vf_sge_start(adapter); - /* Initialize hash mac addr list*/ - INIT_LIST_HEAD(&adapter->mac_hlist); return 0; } -- 1.8.3.1