[PATCH] aacraid: Fix a possible sleep-under-mutex bug in aac_alloc_commands
Jia-Ju Bai
baijiaju1990 at 163.com
Sun Jun 18 14:32:09 UTC 2017
The driver may sleep under a mutex, and the code path is:
aac_alloc_commands [line 1223: acquire the mutex]
aac_alloc_commands [line 1227]
bus_dmamap_create(BUS_DMA_WAITOK) [line 1250] --> may sleep
The possible fix of this bug is to replace "BUS_DMA_WAITOK" in bus_dmamap_create with "BUS_DMA_NOWAIT".
This bug is found by a static analysis tool written by myself, and it is
checked by my review of the FreeBSD code.
Signed-off-by: Jia-Ju Bai <baijiaju1990 at 163.com>
---
sys/dev/aacraid/aacraid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/dev/aacraid/aacraid.c b/sys/dev/aacraid/aacraid.c
index 42a16c42039..b0a987f5903 100644
--- a/sys/dev/aacraid/aacraid.c
+++ b/sys/dev/aacraid/aacraid.c
@@ -1247,7 +1247,7 @@ aac_alloc_commands(struct aac_softc *sc)
}
cm->cm_index = sc->total_fibs;
- if ((error = bus_dmamap_create(sc->aac_buffer_dmat, 0,
+ if ((error = bus_dmamap_create(sc->aac_buffer_dmat, BUS_DMA_NOWAIT,
&cm->cm_datamap)) != 0)
break;
if (sc->aac_max_fibs <= 1 || sc->aac_max_fibs - sc->total_fibs > 1)
--
2.13.0
More information about the freebsd-drivers
mailing list