diff options
author | Stephen Warren <swarren@nvidia.com> | 2013-05-07 18:53:52 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-05-16 20:30:52 -0400 |
commit | 3b9561e9d9b88eca9d4ed6aab025dec2eeeed501 (patch) | |
tree | 6ac9d662f3b7c4ee4411d4fc5103f1226430740a /drivers/usb/host/ohci-omap3.c | |
parent | 8ff10bdb14a52e3f25d4ce09e0582a8684c1a6db (diff) |
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 4a53f4e "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>
Diffstat (limited to 'drivers/usb/host/ohci-omap3.c')
-rw-r--r-- | drivers/usb/host/ohci-omap3.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c index ddfc31427bc0..8663851c8d8e 100644 --- a/drivers/usb/host/ohci-omap3.c +++ b/drivers/usb/host/ohci-omap3.c | |||
@@ -114,8 +114,6 @@ static const struct hc_driver ohci_omap3_hc_driver = { | |||
114 | 114 | ||
115 | /*-------------------------------------------------------------------------*/ | 115 | /*-------------------------------------------------------------------------*/ |
116 | 116 | ||
117 | static u64 omap_ohci_dma_mask = DMA_BIT_MASK(32); | ||
118 | |||
119 | /* | 117 | /* |
120 | * configure so an HC device and id are always provided | 118 | * configure so an HC device and id are always provided |
121 | * always called with process context; sleeping is OK | 119 | * always called with process context; sleeping is OK |
@@ -168,8 +166,10 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev) | |||
168 | * Since shared usb code relies on it, set it here for now. | 166 | * Since shared usb code relies on it, set it here for now. |
169 | * Once we have dma capability bindings this can go away. | 167 | * Once we have dma capability bindings this can go away. |
170 | */ | 168 | */ |
171 | if (!pdev->dev.dma_mask) | 169 | if (!dev->dma_mask) |
172 | pdev->dev.dma_mask = &omap_ohci_dma_mask; | 170 | dev->dma_mask = &dev->coherent_dma_mask; |
171 | if (!dev->coherent_dma_mask) | ||
172 | dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
173 | 173 | ||
174 | hcd = usb_create_hcd(&ohci_omap3_hc_driver, dev, | 174 | hcd = usb_create_hcd(&ohci_omap3_hc_driver, dev, |
175 | dev_name(dev)); | 175 | dev_name(dev)); |