Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Oct 2023 00:32:11 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 4640df1b0a49 - main - mrsas: Fix callout locking in mrsas_complete_cmd()
Message-ID:  <202310070032.3970WBCE005671@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=4640df1b0a49697840b81f6bcd269a483514c6aa

commit 4640df1b0a49697840b81f6bcd269a483514c6aa
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-07 00:31:03 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-07 00:31:03 +0000

    mrsas: Fix callout locking in mrsas_complete_cmd()
    
    callout_stop() requires the associated lock to be held.
    
    This is a bit hacky, but I believe it's safe since the subsequent
    mrsas_cmd_done() call will also acquire the SIM lock to stop a different
    callout.
    
    PR:             265484
    Reviewed by:    imp
    Tested by:      Jérémie Jourdin <jeremie.jourdin@advens.fr>
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D39559
---
 sys/dev/mrsas/mrsas.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/dev/mrsas/mrsas.c b/sys/dev/mrsas/mrsas.c
index 1241f44761c4..e362d4b455fc 100644
--- a/sys/dev/mrsas/mrsas.c
+++ b/sys/dev/mrsas/mrsas.c
@@ -1732,11 +1732,13 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex)
 						data_length = r1_cmd->io_request->DataLength;
 						sense = r1_cmd->sense;
 					}
+					mtx_lock(&sc->sim_lock);
 					r1_cmd->ccb_ptr = NULL;
 					if (r1_cmd->callout_owner) {
 						callout_stop(&r1_cmd->cm_callout);
 						r1_cmd->callout_owner  = false;
 					}
+					mtx_unlock(&sc->sim_lock);
 					mrsas_release_mpt_cmd(r1_cmd);
 					mrsas_atomic_dec(&sc->fw_outstanding);
 					mrsas_map_mpt_cmd_status(cmd_mpt, cmd_mpt->ccb_ptr, status,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310070032.3970WBCE005671>