diff options
author | Jacopo Mondi <jacopo+renesas@jmondi.org> | 2018-04-18 11:42:35 +0200 |
---|---|---|
committer | Rich Felker <dalias@libc.org> | 2018-05-05 16:51:46 -0400 |
commit | b9826a4929bbd4dcb245429fd7434145c4fcdc9b (patch) | |
tree | 8749be4653afdecc99b127e272e27118e553157e /arch/sh/kernel/setup.c | |
parent | 6cb465972c4eb6741b3094a58a65e527fc63c100 (diff) | |
download | linux-stable-b9826a4929bbd4dcb245429fd7434145c4fcdc9b.tar.gz linux-stable-b9826a4929bbd4dcb245429fd7434145c4fcdc9b.tar.bz2 linux-stable-b9826a4929bbd4dcb245429fd7434145c4fcdc9b.zip |
sh: mm: Fix unprotected access to struct device
With commit ce88313069c36eef80f21fd7 ("arch/sh: make the DMA mapping
operations observe dev->dma_pfn_offset") the generic DMA allocation
function on which the SH 'dma_alloc_coherent()' function relies on,
accesses the 'dma_pfn_offset' field of struct device.
Unfortunately the 'dma_generic_alloc_coherent()' function is called from
several places with a NULL struct device argument, halting the CPU
during the boot process.
This patch fixes the issue by protecting access to dev->dma_pfn_offset,
with a trivial check for validity. It also passes a valid 'struct device'
in the 'platform_resource_setup_memory()' function which is the main user
of 'dma_alloc_coherent()', and inserts a WARN_ON() check to remind to future
(and existing) bogus users of this function to provide a valid 'struct device'
whenever possible.
Fixes: ce88313069c36eef80f21fd7 ("arch/sh: make the DMA mapping operations observe dev->dma_pfn_offset")
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Rich Felker <dalias@libc.org>
Diffstat (limited to 'arch/sh/kernel/setup.c')
0 files changed, 0 insertions, 0 deletions