]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
idpf: Acquire the lock before accessing the xn->salt
authorManoj Vishwanathan <manojvishy@google.com>
Mon, 16 Dec 2024 16:27:33 +0000 (16:27 +0000)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 24 Jan 2025 18:03:39 +0000 (10:03 -0800)
The transaction salt was being accessed before acquiring the
idpf_vc_xn_lock when idpf has to forward the virtchnl reply.

Fixes: 34c21fa894a1 ("idpf: implement virtchnl transaction manager")
Signed-off-by: Manoj Vishwanathan <manojvishy@google.com>
Signed-off-by: David Decotigny <decot@google.com>
Signed-off-by: Brian Vazquez <brianvv@google.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
Tested-by: Krishneil Singh <krishneil.k.singh@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

index 7639d520b80630422a429332ba8d1f135fbf56b3..99bdb95bf22661f5ad0c30704d67f2f4ff0cee7d 100644 (file)
@@ -612,14 +612,15 @@ idpf_vc_xn_forward_reply(struct idpf_adapter *adapter,
                return -EINVAL;
        }
        xn = &adapter->vcxn_mngr->ring[xn_idx];
+       idpf_vc_xn_lock(xn);
        salt = FIELD_GET(IDPF_VC_XN_SALT_M, msg_info);
        if (xn->salt != salt) {
                dev_err_ratelimited(&adapter->pdev->dev, "Transaction salt does not match (%02x != %02x)\n",
                                    xn->salt, salt);
+               idpf_vc_xn_unlock(xn);
                return -EINVAL;
        }
 
-       idpf_vc_xn_lock(xn);
        switch (xn->state) {
        case IDPF_VC_XN_WAITING:
                /* success */