The branch main has been updated by whu:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7b9bd54ae86db1ac81d10964be4e3acf1b877495

commit 7b9bd54ae86db1ac81d10964be4e3acf1b877495
Author:     Wei Hu <[email protected]>
AuthorDate: 2023-08-11 03:30:38 +0000
Commit:     Wei Hu <[email protected]>
CommitDate: 2023-08-11 03:30:38 +0000

    mana: fix a KASSERT panic on recursed lock access in mana_cfg_vport
    
    The panic stack looks like this:
    panic: _sx_xlock_hard: recursed on non-recursive sx MANA port lock
    @ /usr/src/sys/dev/mana/mana_en.c:1022
    
    KDB: stack backtrace:
    vpanic() at vpanic+0x150/frame 0xfffffe011b3c1970
    panic() at panic+0x43/frame 0xfffffe011b3c19d0
    _sx_xlock_hard() at _sx_xlock_hard+0x82d/frame 0xfffffe011b3c1a70
    _sx_xlock() at _sx_xlock+0xb0/frame 0xfffffe011b3c1ab0
    mana_cfg_vport() at mana_cfg_vport+0x79/frame 0xfffffe011b3c1b40
    mana_alloc_queues() at mana_alloc_queues+0x3b/frame 0xfffffe011b3c1c50
    mana_up() at mana_up+0x40/frame 0xfffffe011b3c1c70
    mana_ioctl() at mana_ioctl+0x25b/frame 0xfffffe011b3c1cb0
    ifhwioctl() at ifhwioctl+0xd11/frame 0xfffffe011b3c1db0
    hn_xpnt_vf_init() at hn_xpnt_vf_init+0x15f/frame 0xfffffe011b3c1e10
    
    The lock has already been held in the caller. Remove this
    redundant lock attempt.
    
    Reported by:    NetApp
    Sponsored by:   Microsoft
---
 sys/dev/mana/mana_en.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c
index 9d9a4084efe1..4bab6719e59f 100644
--- a/sys/dev/mana/mana_en.c
+++ b/sys/dev/mana/mana_en.c
@@ -983,14 +983,12 @@ mana_query_vport_cfg(struct mana_port_context *apc, 
uint32_t vport_index,
 void
 mana_uncfg_vport(struct mana_port_context *apc)
 {
-       MANA_APC_LOCK_LOCK(apc);
        apc->vport_use_count--;
        if (apc->vport_use_count < 0) {
                mana_err(NULL,
                    "WARNING: vport_use_count less than 0: %u\n",
                    apc->vport_use_count);
        }
-       MANA_APC_LOCK_UNLOCK(apc);
 }
 
 int
@@ -1019,13 +1017,10 @@ mana_cfg_vport(struct mana_port_context *apc, uint32_t 
protection_dom_id,
         * QPs on a physical port up to the hardware limits independent of the
         * Ethernet usage on the same port.
         */
-       MANA_APC_LOCK_LOCK(apc);
        if (apc->vport_use_count > 0) {
-               MANA_APC_LOCK_UNLOCK(apc);
                return EBUSY;
        }
        apc->vport_use_count++;
-       MANA_APC_LOCK_UNLOCK(apc);
 
        mana_gd_init_req_hdr(&req.hdr, MANA_CONFIG_VPORT_TX,
            sizeof(req), sizeof(resp));

Reply via email to