Date: Sun, 18 Jun 2017 23:13:29 +0800 From: Jia-Ju Bai <baijiaju1990@163.com> To: erj@freebsd.org, sbruno@freebsd.org Cc: freebsd-drivers@freebsd.org, freebsd-bugs@freebsd.org, freebsd-net@freebsd.org, Jia-Ju Bai <baijiaju1990@163.com> Subject: [PATCH] if_ixgb: Fix possible sleep-under-mutex bugs (different from Bug 220033) Message-ID: <20170618151329.41975-1-baijiaju1990@163.com>
next in thread | raw e-mail | index | archive | help
The driver may sleep under a mutex, and the function call paths are: ixgb_init [acquire the mutex] ixgb_init_locked ixgb_setup_transmit_structures bus_dma_tag_create(BUS_DMA_ALLOCNOW) --> may sleep ixgb_init [acquire the mutex] ixgb_init_locked ixgb_setup_receive_structures ixgb_allocate_receive_structures bus_dma_tag_create(BUS_DMA_ALLOCNOW) --> may sleep The possible fix of these bugs is to add "BUS_DMA_NOWAIT" in bus_dma_tag_create. These bugs are 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/ixgb/if_ixgb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/ixgb/if_ixgb.c b/sys/dev/ixgb/if_ixgb.c index 430c13c72d1..4cdfe6d4c28 100644 --- a/sys/dev/ixgb/if_ixgb.c +++ b/sys/dev/ixgb/if_ixgb.c @@ -1518,7 +1518,7 @@ ixgb_setup_transmit_structures(struct adapter * adapter) MCLBYTES * IXGB_MAX_SCATTER, /* maxsize */ IXGB_MAX_SCATTER, /* nsegments */ MCLBYTES, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ + BUS_DMA_ALLOCNOW | BUS_DMA_NOWAIT, /* flags */ #if __FreeBSD_version >= 502000 NULL, /* lockfunc */ NULL, /* lockfuncarg */ @@ -1856,7 +1856,7 @@ ixgb_allocate_receive_structures(struct adapter * adapter) MCLBYTES, /* maxsize */ 1, /* nsegments */ MCLBYTES, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ + BUS_DMA_ALLOCNOW | BUS_DMA_NOWAIT, /* flags */ #if __FreeBSD_version >= 502000 NULL, /* lockfunc */ NULL, /* lockfuncarg */ -- 2.13.0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170618151329.41975-1-baijiaju1990>