Commit b05004ad authored by Somnath Kotur's avatar Somnath Kotur Committed by David S. Miller

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: default avatarKalesh AP <kalesh.purayil@emulex.com>
Signed-off-by: default avatarSomnath Kotur <somnath.kotur@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4bebb56a
...@@ -2940,28 +2940,35 @@ static void be_cancel_worker(struct be_adapter *adapter) ...@@ -2940,28 +2940,35 @@ static void be_cancel_worker(struct be_adapter *adapter)
} }
} }
static int be_clear(struct be_adapter *adapter) static void be_mac_clear(struct be_adapter *adapter)
{ {
int i; int i;
if (adapter->pmac_id) {
for (i = 0; i < (adapter->uc_macs + 1); i++)
be_cmd_pmac_del(adapter, adapter->if_handle,
adapter->pmac_id[i], 0);
adapter->uc_macs = 0;
kfree(adapter->pmac_id);
adapter->pmac_id = NULL;
}
}
static int be_clear(struct be_adapter *adapter)
{
be_cancel_worker(adapter); be_cancel_worker(adapter);
if (sriov_enabled(adapter)) if (sriov_enabled(adapter))
be_vf_clear(adapter); be_vf_clear(adapter);
/* delete the primary mac along with the uc-mac list */ /* delete the primary mac along with the uc-mac list */
for (i = 0; i < (adapter->uc_macs + 1); i++) be_mac_clear(adapter);
be_cmd_pmac_del(adapter, adapter->if_handle,
adapter->pmac_id[i], 0);
adapter->uc_macs = 0;
be_cmd_if_destroy(adapter, adapter->if_handle, 0); be_cmd_if_destroy(adapter, adapter->if_handle, 0);
be_clear_queues(adapter); be_clear_queues(adapter);
kfree(adapter->pmac_id);
adapter->pmac_id = NULL;
be_msix_disable(adapter); be_msix_disable(adapter);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment