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 <[email protected]>
---
 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


_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[email protected]"

Reply via email to