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/dwc3/dwc3-exynos.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/dwc3/dwc3-exynos.c')
-rw-r--r-- | drivers/usb/dwc3/dwc3-exynos.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index a8afe6e26621..929e7dd6e58b 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
@@ -95,8 +95,6 @@ static int dwc3_exynos_remove_child(struct device *dev, void *unused) | |||
95 | return 0; | 95 | return 0; |
96 | } | 96 | } |
97 | 97 | ||
98 | static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32); | ||
99 | |||
100 | static int dwc3_exynos_probe(struct platform_device *pdev) | 98 | static int dwc3_exynos_probe(struct platform_device *pdev) |
101 | { | 99 | { |
102 | struct dwc3_exynos *exynos; | 100 | struct dwc3_exynos *exynos; |
@@ -118,7 +116,9 @@ static int dwc3_exynos_probe(struct platform_device *pdev) | |||
118 | * Once we move to full device tree support this will vanish off. | 116 | * Once we move to full device tree support this will vanish off. |
119 | */ | 117 | */ |
120 | if (!dev->dma_mask) | 118 | if (!dev->dma_mask) |
121 | dev->dma_mask = &dwc3_exynos_dma_mask; | 119 | dev->dma_mask = &dev->coherent_dma_mask; |
120 | if (!dev->coherent_dma_mask) | ||
121 | dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
122 | 122 | ||
123 | platform_set_drvdata(pdev, exynos); | 123 | platform_set_drvdata(pdev, exynos); |
124 | 124 | ||