Date: Sun, 18 Jun 2017 22:31:59 +0800 From: Jia-Ju Bai <baijiaju1990@163.com> To: freebsd-drivers@freebsd.org, freebsd-bugs@freebsd.org Cc: Jia-Ju Bai <baijiaju1990@163.com> Subject: [PATCH] aacraid: Fix a possible sleep-under-mutex bug in aac_alloc_commands Message-ID: <20170618143159.41761-1-baijiaju1990@163.com>
next in thread | raw e-mail | index | archive | help
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@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170618143159.41761-1-baijiaju1990>