USB: set device dma_mask without reference to global data
Many USB host drivers contain code such as: if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &tegra_ehci_dma_mask; ... where tegra_ehci_dma_mask is a global. I suspect this code originated in commit 4a53f4e6 "USB: ehci-tegra: add probing through device tree" and was simply copied everywhere else. This works fine when the code is built-in, but can cause a crash when the code is in a module. The first module load sets up the dma_mask pointer, but if the module is removed and re-inserted, the value is now non-NULL, and hence is not updated to point at the new location, and hence points at a stale location within the previous module load address, which in turn causes a crash if the pointer is de-referenced. The simplest way of solving this seems to be to copy the code from ehci-platform.c, which uses the coherent_dma_mask as the target for the dma_mask pointer. Suggested-by:Arnd Bergmann <arnd@arndb.de> Signed-off-by:
Stephen Warren <swarren@nvidia.com> Acked-by:
Tony Prisk <linux@prisktech.co.nz> Signed-off-by:
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing
- drivers/usb/chipidea/ci13xxx_imx.c 4 additions, 11 deletionsdrivers/usb/chipidea/ci13xxx_imx.c
- drivers/usb/dwc3/dwc3-exynos.c 3 additions, 3 deletionsdrivers/usb/dwc3/dwc3-exynos.c
- drivers/usb/host/ehci-atmel.c 3 additions, 3 deletionsdrivers/usb/host/ehci-atmel.c
- drivers/usb/host/ehci-omap.c 4 additions, 4 deletionsdrivers/usb/host/ehci-omap.c
- drivers/usb/host/ehci-orion.c 3 additions, 3 deletionsdrivers/usb/host/ehci-orion.c
- drivers/usb/host/ehci-s5p.c 1 addition, 3 deletionsdrivers/usb/host/ehci-s5p.c
- drivers/usb/host/ehci-spear.c 3 additions, 3 deletionsdrivers/usb/host/ehci-spear.c
- drivers/usb/host/ehci-tegra.c 3 additions, 3 deletionsdrivers/usb/host/ehci-tegra.c
- drivers/usb/host/ohci-at91.c 3 additions, 3 deletionsdrivers/usb/host/ohci-at91.c
- drivers/usb/host/ohci-exynos.c 1 addition, 3 deletionsdrivers/usb/host/ohci-exynos.c
- drivers/usb/host/ohci-omap3.c 4 additions, 4 deletionsdrivers/usb/host/ohci-omap3.c
- drivers/usb/host/ohci-pxa27x.c 3 additions, 3 deletionsdrivers/usb/host/ohci-pxa27x.c
- drivers/usb/host/ohci-spear.c 3 additions, 3 deletionsdrivers/usb/host/ohci-spear.c
- drivers/usb/host/uhci-platform.c 3 additions, 3 deletionsdrivers/usb/host/uhci-platform.c
Loading
Please register or sign in to comment