aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorSomnath Kotur <somnath.kotur@emulex.com>2013-12-05 01:38:16 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-06 15:03:40 -0500
commitb05004adf9d34e7fb8e96fe6a7cdeb0843f5ab35 (patch)
tree95a9a5f6e67ae6361f16f88297348c9874578231 /drivers/net/ethernet
parent4bebb56a6d50ca50a34048194877dca34f572f8f (diff)
be2net: Free/delete pmacs (in be_clear()) only if they exist
During suspend-resume and lancer error recovery we will cleanup and re-initialize the resources through be_clear() and be_setup() respectively. During re-initialisation in be_setup(), if be_get_config() fails, we'll again call be_clear() which will cause a NULL pointer dereference as adapter->pmac_id is already freed. Signed-off-by: Kalesh AP <kalesh.purayil@emulex.com> Signed-off-by: Somnath Kotur <somnath.kotur@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index a2302dc061f3..0fde69d5cb6a 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2940,28 +2940,35 @@ static void be_cancel_worker(struct be_adapter *adapter)
2940 } 2940 }
2941} 2941}
2942 2942
2943static int be_clear(struct be_adapter *adapter) 2943static void be_mac_clear(struct be_adapter *adapter)
2944{ 2944{
2945 int i; 2945 int i;
2946 2946
2947 if (adapter->pmac_id) {
2948 for (i = 0; i < (adapter->uc_macs + 1); i++)
2949 be_cmd_pmac_del(adapter, adapter->if_handle,
2950 adapter->pmac_id[i], 0);
2951 adapter->uc_macs = 0;
2952
2953 kfree(adapter->pmac_id);
2954 adapter->pmac_id = NULL;
2955 }
2956}
2957
2958static int be_clear(struct be_adapter *adapter)
2959{
2947 be_cancel_worker(adapter); 2960 be_cancel_worker(adapter);
2948 2961
2949 if (sriov_enabled(adapter)) 2962 if (sriov_enabled(adapter))
2950 be_vf_clear(adapter); 2963 be_vf_clear(adapter);
2951 2964
2952 /* delete the primary mac along with the uc-mac list */ 2965 /* delete the primary mac along with the uc-mac list */
2953 for (i = 0; i < (adapter->uc_macs + 1); i++) 2966 be_mac_clear(adapter);
2954 be_cmd_pmac_del(adapter, adapter->if_handle,
2955 adapter->pmac_id[i], 0);
2956 adapter->uc_macs = 0;
2957 2967
2958 be_cmd_if_destroy(adapter, adapter->if_handle, 0); 2968 be_cmd_if_destroy(adapter, adapter->if_handle, 0);
2959 2969
2960 be_clear_queues(adapter); 2970 be_clear_queues(adapter);
2961 2971
2962 kfree(adapter->pmac_id);
2963 adapter->pmac_id = NULL;
2964
2965 be_msix_disable(adapter); 2972 be_msix_disable(adapter);
2966 return 0; 2973 return 0;
2967} 2974}