Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Jun 2017 22:45:35 +0800
From:      Jia-Ju Bai <baijiaju1990@163.com>
To:        njm@njm.me.uk, freebsd-drivers@freebsd.org, freebsd-bugs@freebsd.org, freebsd-scsi@freebsd.org
Cc:        Jia-Ju Bai <baijiaju1990@163.com>
Subject:   [PATCH] dpt_scsi: Fix a possible sleep-under-mutex bug in dpt_init (different from Bug 220095)
Message-ID:  <20170618144535.41858-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:
dpt_init [line 1134: acquire the mutex]
  bus_dma_tag_create(BUS_DMA_WAITOK) [line 1143] --> may sleep

The possible fix of this bug is to replace "BUS_DMA_WAITOK" in bus_dma_tag_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/dpt/dpt_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/dpt/dpt_scsi.c b/sys/dev/dpt/dpt_scsi.c
index 541b58665cf..d69a443067a 100644
--- a/sys/dev/dpt/dpt_scsi.c
+++ b/sys/dev/dpt/dpt_scsi.c
@@ -1150,7 +1150,7 @@ dpt_init(struct dpt_softc *dpt)
 				/* maxsize	*/ PAGE_SIZE,
 				/* nsegments	*/ 1,
 				/* maxsegsz	*/ BUS_SPACE_MAXSIZE_32BIT,
-				/* flags	*/ 0,
+				/* flags	*/ BUS_DMA_NOWAIT,
 				/* lockfunc	*/ NULL,
 				/* lockarg	*/ NULL,
 				&dpt->sg_dmat) != 0) {
-- 
2.13.0





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