Skip to content

Commit 14696ed

Browse files
atbrady-intelanguy11
authored andcommitted
idpf: prevent deinit uninitialized virtchnl core
In idpf_remove we need to tear down the virtchnl core with idpf_vc_core_deinit so we can free up resources and leave things in a good state. However, in the case where we failed to establish VC communications we may not have ever actually successfully initialized the virtchnl core. This fixes it by setting a bit once we successfully init the virtchnl core. Then, in deinit, we'll check for it before going on further, otherwise we just return. Also clear the bit at the end of deinit so we know it's gone now. Tested-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: Alan Brady <alan.brady@intel.com> Tested-by: Krishneil Singh <krishneil.k.singh@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent bcbedf2 commit 14696ed

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ enum idpf_state {
8383
* @IDPF_HR_RESET_IN_PROG: Reset in progress
8484
* @IDPF_REMOVE_IN_PROG: Driver remove in progress
8585
* @IDPF_MB_INTR_MODE: Mailbox in interrupt mode
86+
* @IDPF_VC_CORE_INIT: virtchnl core has been init
8687
* @IDPF_FLAGS_NBITS: Must be last
8788
*/
8889
enum idpf_flags {
@@ -91,6 +92,7 @@ enum idpf_flags {
9192
IDPF_HR_RESET_IN_PROG,
9293
IDPF_REMOVE_IN_PROG,
9394
IDPF_MB_INTR_MODE,
95+
IDPF_VC_CORE_INIT,
9496
IDPF_FLAGS_NBITS,
9597
};
9698

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,7 +2990,9 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
29902990
queue_delayed_work(adapter->init_wq, &adapter->init_task,
29912991
msecs_to_jiffies(5 * (adapter->pdev->devfn & 0x07)));
29922992

2993-
goto no_err;
2993+
set_bit(IDPF_VC_CORE_INIT, adapter->flags);
2994+
2995+
return 0;
29942996

29952997
err_intr_req:
29962998
cancel_delayed_work_sync(&adapter->serv_task);
@@ -2999,7 +3001,6 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
29993001
err_netdev_alloc:
30003002
kfree(adapter->vports);
30013003
adapter->vports = NULL;
3002-
no_err:
30033004
return err;
30043005

30053006
init_failed:
@@ -3034,6 +3035,9 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
30343035
*/
30353036
void idpf_vc_core_deinit(struct idpf_adapter *adapter)
30363037
{
3038+
if (!test_bit(IDPF_VC_CORE_INIT, adapter->flags))
3039+
return;
3040+
30373041
idpf_vc_xn_shutdown(adapter->vcxn_mngr);
30383042
idpf_deinit_task(adapter);
30393043
idpf_intr_rel(adapter);
@@ -3045,6 +3049,8 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter)
30453049

30463050
kfree(adapter->vports);
30473051
adapter->vports = NULL;
3052+
3053+
clear_bit(IDPF_VC_CORE_INIT, adapter->flags);
30483054
}
30493055

30503056
/**

0 commit comments

Comments
 (0)