Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jan 2021 18:32:31 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: 8ba6acbbe699 - main - safexcel: Stop using a stack buffer for the ring lock name
Message-ID:  <202101081832.108IWV88056830@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=8ba6acbbe6995efcd12c375e1826d55e35a8bdc9

commit 8ba6acbbe6995efcd12c375e1826d55e35a8bdc9
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-01-08 18:32:04 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-01-08 18:32:04 +0000

    safexcel: Stop using a stack buffer for the ring lock name
    
    mtx_init() does not make a copy of the name so the buffer must be valid
    for the lifetime of the driver instance.  Store each ring's lock's name
    in the ring structure.
    
    MFC after:      3 days
    Sponsored by:   Rubicon Communications, LLC (Netgate)
---
 sys/dev/safexcel/safexcel.c     | 6 +++---
 sys/dev/safexcel/safexcel_var.h | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/dev/safexcel/safexcel.c b/sys/dev/safexcel/safexcel.c
index 2ed6bed64136..2fd13cd3f6da 100644
--- a/sys/dev/safexcel/safexcel.c
+++ b/sys/dev/safexcel/safexcel.c
@@ -783,15 +783,15 @@ safexcel_init_rings(struct safexcel_softc *sc)
 {
 	struct safexcel_cmd_descr *cdesc;
 	struct safexcel_ring *ring;
-	char buf[32];
 	uint64_t atok;
 	int i, j;
 
 	for (i = 0; i < sc->sc_config.rings; i++) {
 		ring = &sc->sc_ring[i];
 
-		snprintf(buf, sizeof(buf), "safexcel_ring%d", i);
-		mtx_init(&ring->mtx, buf, NULL, MTX_DEF);
+		snprintf(ring->lockname, sizeof(ring->lockname),
+		    "safexcel_ring%d", i);
+		mtx_init(&ring->mtx, ring->lockname, NULL, MTX_DEF);
 		STAILQ_INIT(&ring->free_requests);
 		STAILQ_INIT(&ring->ready_requests);
 		STAILQ_INIT(&ring->queued_requests);
diff --git a/sys/dev/safexcel/safexcel_var.h b/sys/dev/safexcel/safexcel_var.h
index 619bcff00c57..03e5e7da51fc 100644
--- a/sys/dev/safexcel/safexcel_var.h
+++ b/sys/dev/safexcel/safexcel_var.h
@@ -384,6 +384,8 @@ struct safexcel_ring {
 
 	struct safexcel_dma_mem		dma_atok;
 	bus_dma_tag_t   		data_dtag;
+
+	char				lockname[32];
 };
 
 struct safexcel_intr_handle {



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