git: 8ba6acbbe699 - main - safexcel: Stop using a stack buffer for the ring lock name
Mark Johnston
markj at FreeBSD.org
Fri Jan 8 18:32:32 UTC 2021
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=8ba6acbbe6995efcd12c375e1826d55e35a8bdc9
commit 8ba6acbbe6995efcd12c375e1826d55e35a8bdc9
Author: Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-01-08 18:32:04 +0000
Commit: Mark Johnston <markj at 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 {
More information about the dev-commits-src-main
mailing list