• Zhen Lei's avatar
    dma-mapping: avoid oops when parameter cpu_addr is null · d6b7eaeb
    Zhen Lei authored
    To keep consistent with kfree, which tolerate ptr is NULL.  We do this
    because sometimes we may use goto statement, so that success and failure
    case can share parts of the code.  But unfortunately, dma_free_coherent
    called with parameter cpu_addr is null will cause oops, such as showed
      Unable to handle kernel paging request at virtual address ffffffc020d3b2b8
      pgd = ffffffc083a61000
      [ffffffc020d3b2b8] *pgd=0000000000000000, *pud=0000000000000000
      CPU: 4 PID: 1489 Comm: malloc_dma_1 Tainted: G           O    4.1.12 #1
      Hardware name: ARM64 (DT)
      PC is at __dma_free_coherent.isra.10+0x74/0xc8
      LR is at __dma_free+0x9c/0xb0
      Process malloc_dma_1 (pid: 1489, stack limit = 0xffffffc0837fc020)
      Call trace:
        malloc_dma+0x104/0x158 [dma_alloc_coherent_mtmalloc]
    Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
dma-mapping.h 20.3 KB