diff options
author | Lad, Prabhakar <prabhakar.csengg@gmail.com> | 2014-01-29 17:05:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-29 19:22:39 -0500 |
commit | 0368dfd01ae3b7647ef9b2f0525fdefd5e0d28e1 (patch) | |
tree | 333d316aee4c50851b7a2c07defa930e97d17380 /lib/genalloc.c | |
parent | 0e47c969c65e213421450c31043353ebe3c67e0c (diff) |
lib/genalloc.c: add check gen_pool_dma_alloc() if dma pointer is not NULL
In the gen_pool_dma_alloc() the dma pointer can be NULL and while
assigning gen_pool_virt_to_phys(pool, vaddr) to dma caused the following
crash on da850 evm:
Unable to handle kernel NULL pointer dereference at virtual address 00000000
Internal error: Oops: 805 [#1] PREEMPT ARM
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Tainted: G W 3.13.0-rc1-00001-g0609e45-dirty #5
task: c4830000 ti: c4832000 task.ti: c4832000
PC is at gen_pool_dma_alloc+0x30/0x3c
LR is at gen_pool_virt_to_phys+0x74/0x80
Process swapper, call trace:
gen_pool_dma_alloc+0x30/0x3c
davinci_pm_probe+0x40/0xa8
platform_drv_probe+0x1c/0x4c
driver_probe_device+0x98/0x22c
__driver_attach+0x8c/0x90
bus_for_each_dev+0x6c/0x8c
bus_add_driver+0x124/0x1d4
driver_register+0x78/0xf8
platform_driver_probe+0x20/0xa4
davinci_init_late+0xc/0x14
init_machine_late+0x1c/0x28
do_one_initcall+0x34/0x15c
kernel_init_freeable+0xe4/0x1ac
kernel_init+0x8/0xec
This patch fixes the above.
[akpm@linux-foundation.org: update kerneldoc]
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Nicolin Chen <b42378@freescale.com>
Cc: Joe Perches <joe@perches.com>
Cc: Sachin Kamat <sachin.kamat@linaro.org>
Cc: <stable@vger.kernel.org> [3.13.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/genalloc.c')
-rw-r--r-- | lib/genalloc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/genalloc.c b/lib/genalloc.c index dda31168844f..bdb9a456bcbb 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c | |||
@@ -316,7 +316,7 @@ EXPORT_SYMBOL(gen_pool_alloc); | |||
316 | * gen_pool_dma_alloc - allocate special memory from the pool for DMA usage | 316 | * gen_pool_dma_alloc - allocate special memory from the pool for DMA usage |
317 | * @pool: pool to allocate from | 317 | * @pool: pool to allocate from |
318 | * @size: number of bytes to allocate from the pool | 318 | * @size: number of bytes to allocate from the pool |
319 | * @dma: dma-view physical address | 319 | * @dma: dma-view physical address return value. Use NULL if unneeded. |
320 | * | 320 | * |
321 | * Allocate the requested number of bytes from the specified pool. | 321 | * Allocate the requested number of bytes from the specified pool. |
322 | * Uses the pool allocation function (with first-fit algorithm by default). | 322 | * Uses the pool allocation function (with first-fit algorithm by default). |
@@ -334,7 +334,8 @@ void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma) | |||
334 | if (!vaddr) | 334 | if (!vaddr) |
335 | return NULL; | 335 | return NULL; |
336 | 336 | ||
337 | *dma = gen_pool_virt_to_phys(pool, vaddr); | 337 | if (dma) |
338 | *dma = gen_pool_virt_to_phys(pool, vaddr); | ||
338 | 339 | ||
339 | return (void *)vaddr; | 340 | return (void *)vaddr; |
340 | } | 341 | } |