[SRU][J:gcp/gke, N:gcp/gke/gkeop][PATCH 3/5] idpf: fix idpf_vc_core_init error path

Ian Whitfield ian.whitfield at canonical.com
Sun Jan 12 04:18:20 UTC 2025


From: Pavan Kumar Linga <pavan.kumar.linga at intel.com>

BugLink: https://bugs.launchpad.net/bugs/2093622

In an event where the platform running the device control plane
is rebooted, reset is detected on the driver. It releases
all the resources and waits for the reset to complete. Once the
reset is done, it tries to build the resources back. At this
time if the device control plane is not yet started, then
the driver timeouts on the virtchnl message and retries to
establish the mailbox again.

In the retry flow, mailbox is deinitialized but the mailbox
workqueue is still alive and polling for the mailbox message.
This results in accessing the released control queue leading to
null-ptr-deref. Fix it by unrolling the work queue cancellation
and mailbox deinitialization in the reverse order which they got
initialized.

Fixes: 4930fbf419a7 ("idpf: add core init and interrupt request")
Fixes: 34c21fa894a1 ("idpf: implement virtchnl transaction manager")
Cc: stable at vger.kernel.org # 6.9+
Reviewed-by: Tarun K Singh <tarun.k.singh at intel.com>
Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga at intel.com>
Tested-by: Krishneil Singh <krishneil.k.singh at intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen at intel.com>
(backported from commit 9b58031ff96b84a38d7b73b23c7ecfb2e0557f43)
[ijwhitfield: Context adjusted due to missing commit:
34c21fa894a1a ("idpf: implement virtchnl transaction manager")]
Signed-off-by: Ian Whitfield <ian.whitfield at canonical.com>
---
 drivers/net/ethernet/intel/idpf/idpf_lib.c      | 1 +
 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
index f769a9fc1084..0497366ae9c2 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
@@ -1829,6 +1829,7 @@ static int idpf_init_hard_reset(struct idpf_adapter *adapter)
 	 */
 	err = idpf_vc_core_init(adapter);
 	if (err) {
+		cancel_delayed_work_sync(&adapter->mbx_task);
 		idpf_deinit_dflt_mbx(adapter);
 		goto unlock_mutex;
 	}
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index 13a9cce16879..64ede79c1728 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
@@ -3171,7 +3171,6 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
 	 * the mailbox again
 	 */
 	adapter->state = __IDPF_STARTUP;
-	idpf_deinit_dflt_mbx(adapter);
 	set_bit(IDPF_HR_DRV_LOAD, adapter->flags);
 	queue_delayed_work(adapter->vc_event_wq, &adapter->vc_event_task,
 			   msecs_to_jiffies(task_delay));
-- 
2.43.0




More information about the kernel-team mailing list