* [PATCH net-next] cxgb4/cxgb4vf: Fix mac_hlist initialization and free
@ 2018-11-19 10:07 Arjun Vynipadath
2018-11-19 19:24 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Arjun Vynipadath @ 2018-11-19 10:07 UTC (permalink / raw)
To: netdev, davem
Cc: nirranjan, indranil, dt, Arjun Vynipadath, Casey Leedom,
Ganesh Goudar
Null pointer dereference seen when cxgb4vf driver is unloaded
without bringing up any interfaces, moving mac_hlist initialization
to driver probe and free the mac_hlist in remove to fix this.
Fixes 'commit 24357e06ba51 ("cxgb4vf: fix memleak in mac_hlist
initialization")'
Signed-off-by: Arjun Vynipadath <arjun@chelsio.com>
Signed-off-by: Casey Leedom <leedom@chelsio.com>
Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 19 ++++++++++---------
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 6 +++---
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 956e708..cdd6f48 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2280,8 +2280,6 @@ static int cxgb_up(struct adapter *adap)
#if IS_ENABLED(CONFIG_IPV6)
update_clip(adap);
#endif
- /* Initialize hash mac addr list*/
- INIT_LIST_HEAD(&adap->mac_hlist);
return err;
irq_err:
@@ -2295,8 +2293,6 @@ static int cxgb_up(struct adapter *adap)
static void cxgb_down(struct adapter *adapter)
{
- struct hash_mac_addr *entry, *tmp;
-
cancel_work_sync(&adapter->tid_release_task);
cancel_work_sync(&adapter->db_full_task);
cancel_work_sync(&adapter->db_drop_task);
@@ -2306,11 +2302,6 @@ static void cxgb_down(struct adapter *adapter)
t4_sge_stop(adapter);
t4_free_sge_resources(adapter);
- list_for_each_entry_safe(entry, tmp, &adapter->mac_hlist, list) {
- list_del(&entry->list);
- kfree(entry);
- }
-
adapter->flags &= ~FULL_INIT_DONE;
}
@@ -5629,6 +5620,9 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
(is_t5(adapter->params.chip) ? STATMODE_V(0) :
T6_STATMODE_V(0)));
+ /* Initialize hash mac addr list */
+ INIT_LIST_HEAD(&adapter->mac_hlist);
+
for_each_port(adapter, i) {
netdev = alloc_etherdev_mq(sizeof(struct port_info),
MAX_ETH_QSETS);
@@ -5907,6 +5901,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
static void remove_one(struct pci_dev *pdev)
{
struct adapter *adapter = pci_get_drvdata(pdev);
+ struct hash_mac_addr *entry, *tmp;
if (!adapter) {
pci_release_regions(pdev);
@@ -5956,6 +5951,12 @@ static void remove_one(struct pci_dev *pdev)
if (adapter->num_uld || adapter->num_ofld_uld)
t4_uld_mem_free(adapter);
free_some_resources(adapter);
+ list_for_each_entry_safe(entry, tmp, &adapter->mac_hlist,
+ list) {
+ list_del(&entry->list);
+ kfree(entry);
+ }
+
#if IS_ENABLED(CONFIG_IPV6)
t4_cleanup_clip_tbl(adapter);
#endif
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index 8ec503c..8a2ad6b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -723,9 +723,6 @@ 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;
}
@@ -3038,6 +3035,9 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
if (err)
goto err_unmap_bar;
+ /* Initialize hash mac addr list */
+ INIT_LIST_HEAD(&adapter->mac_hlist);
+
/*
* Allocate our "adapter ports" and stitch everything together.
*/
--
2.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] cxgb4/cxgb4vf: Fix mac_hlist initialization and free
2018-11-19 10:07 [PATCH net-next] cxgb4/cxgb4vf: Fix mac_hlist initialization and free Arjun Vynipadath
@ 2018-11-19 19:24 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2018-11-19 19:24 UTC (permalink / raw)
To: Arjun Vynipadath
Cc: netdev, davem, nirranjan, indranil, dt, Casey Leedom,
Ganesh Goudar
[-- Attachment #1: Type: text/plain, Size: 3888 bytes --]
On Mon, Nov 19, 2018 at 03:37:34PM +0530, Arjun Vynipadath wrote:
> Null pointer dereference seen when cxgb4vf driver is unloaded
> without bringing up any interfaces, moving mac_hlist initialization
> to driver probe and free the mac_hlist in remove to fix this.
>
> Fixes 'commit 24357e06ba51 ("cxgb4vf: fix memleak in mac_hlist
> initialization")'
>
Please don't break Fixes line (it is needed to various scripts) and no
extra line between Fixes and SOB.
Thanks
> Signed-off-by: Arjun Vynipadath <arjun@chelsio.com>
> Signed-off-by: Casey Leedom <leedom@chelsio.com>
> Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com>
> ---
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 19 ++++++++++---------
> drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 6 +++---
> 2 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> index 956e708..cdd6f48 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> @@ -2280,8 +2280,6 @@ static int cxgb_up(struct adapter *adap)
> #if IS_ENABLED(CONFIG_IPV6)
> update_clip(adap);
> #endif
> - /* Initialize hash mac addr list*/
> - INIT_LIST_HEAD(&adap->mac_hlist);
> return err;
>
> irq_err:
> @@ -2295,8 +2293,6 @@ static int cxgb_up(struct adapter *adap)
>
> static void cxgb_down(struct adapter *adapter)
> {
> - struct hash_mac_addr *entry, *tmp;
> -
> cancel_work_sync(&adapter->tid_release_task);
> cancel_work_sync(&adapter->db_full_task);
> cancel_work_sync(&adapter->db_drop_task);
> @@ -2306,11 +2302,6 @@ static void cxgb_down(struct adapter *adapter)
> t4_sge_stop(adapter);
> t4_free_sge_resources(adapter);
>
> - list_for_each_entry_safe(entry, tmp, &adapter->mac_hlist, list) {
> - list_del(&entry->list);
> - kfree(entry);
> - }
> -
> adapter->flags &= ~FULL_INIT_DONE;
> }
>
> @@ -5629,6 +5620,9 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> (is_t5(adapter->params.chip) ? STATMODE_V(0) :
> T6_STATMODE_V(0)));
>
> + /* Initialize hash mac addr list */
> + INIT_LIST_HEAD(&adapter->mac_hlist);
> +
> for_each_port(adapter, i) {
> netdev = alloc_etherdev_mq(sizeof(struct port_info),
> MAX_ETH_QSETS);
> @@ -5907,6 +5901,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> static void remove_one(struct pci_dev *pdev)
> {
> struct adapter *adapter = pci_get_drvdata(pdev);
> + struct hash_mac_addr *entry, *tmp;
>
> if (!adapter) {
> pci_release_regions(pdev);
> @@ -5956,6 +5951,12 @@ static void remove_one(struct pci_dev *pdev)
> if (adapter->num_uld || adapter->num_ofld_uld)
> t4_uld_mem_free(adapter);
> free_some_resources(adapter);
> + list_for_each_entry_safe(entry, tmp, &adapter->mac_hlist,
> + list) {
> + list_del(&entry->list);
> + kfree(entry);
> + }
> +
> #if IS_ENABLED(CONFIG_IPV6)
> t4_cleanup_clip_tbl(adapter);
> #endif
> diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
> index 8ec503c..8a2ad6b 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
> @@ -723,9 +723,6 @@ 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;
> }
>
> @@ -3038,6 +3035,9 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
> if (err)
> goto err_unmap_bar;
>
> + /* Initialize hash mac addr list */
> + INIT_LIST_HEAD(&adapter->mac_hlist);
> +
> /*
> * Allocate our "adapter ports" and stitch everything together.
> */
> --
> 2.9.5
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-20 5:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-19 10:07 [PATCH net-next] cxgb4/cxgb4vf: Fix mac_hlist initialization and free Arjun Vynipadath
2018-11-19 19:24 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).