From a893539e9572175b7dfd95822643cc46b43ec9e2 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Tue, 13 May 2008 20:58:08 +0000 Subject: [PATCH] Don't let hacksync() call bus_dmamap_sync(9) on DMA maps which are not initialized. This fixes a panic on sparc64 where calling bus_dmamap_sync(9) on NULL DMA maps is fatal. Approved by: sam --- sys/dev/usb/ehci.c | 10 +++++++--- sys/dev/usb/ohci.c | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index 2cd5bc5c534..d15ccb4ab0b 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -661,9 +661,13 @@ ehci_pcd_enable(void *v_sc) static __inline void hacksync(usbd_xfer_handle xfer) { - usbd_pipe_handle pipe = xfer->pipe; - bus_dma_tag_t tag = pipe->device->bus->buffer_dmatag; - struct usb_dma_mapping *dmap = &xfer->dmamap; + bus_dma_tag_t tag; + struct usb_dma_mapping *dmap; + + if (xfer->length == 0) + return; + tag = xfer->pipe->device->bus->buffer_dmatag; + dmap = &xfer->dmamap; bus_dmamap_sync(tag, dmap->map, BUS_DMASYNC_PREWRITE); } diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index 3b953025f91..7afc0c2ed4c 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1568,9 +1568,13 @@ ohci_device_bulk_done(usbd_xfer_handle xfer) static __inline void hacksync(usbd_xfer_handle xfer) { - usbd_pipe_handle pipe = xfer->pipe; - bus_dma_tag_t tag = pipe->device->bus->buffer_dmatag; - struct usb_dma_mapping *dmap = &xfer->dmamap; + bus_dma_tag_t tag; + struct usb_dma_mapping *dmap; + + if (xfer->length == 0) + return; + tag = xfer->pipe->device->bus->buffer_dmatag; + dmap = &xfer->dmamap; bus_dmamap_sync(tag, dmap->map, BUS_DMASYNC_PREWRITE); }