• Yoshihiro Shimoda's avatar
    serial: sh-sci: Fix NULL pointer dereference if HIGHMEM is enabled · 7b39d901
    Yoshihiro Shimoda authored
    This patch fixes an issue that this driver causes a NULL pointer
    dereference in the following conditions:
     - CONFIG_HIGHMEM and CONFIG_SERIAL_SH_SCI_DMA are enabled
     - This driver runs on the sci_dma_rx_push()
    
    This issue was caused by virt_to_page(buf) in the sci_request_dma()
    because this driver didn't check if the "buf" was valid or not.  So,
    this patch uses the "buf" from dma_alloc_coherent() as is, not page.
    
    This patch also fixes a WARNING issue in sci_rx_dma_release():
    
        WARNING: CPU: 0 PID: 1328 at lib/dma-debug.c:1125 check_unmap+0x444/0x848()
        rcar-dmac e6700000.dma-controller: DMA-API: device driver frees DMA memory with different CPU address [device address=0x000000006dd89000] [size=64 bytes] [cpu alloc address=0x000000016189c000] [cpu free address=0x0000000080000000]
    
        WARNING: CPU: 1 PID: 1 at drivers/base/dma-mapping.c:334 dma_common_free_remap+0x48/0x6c()
        trying to free invalid coherent area:   (null)
    Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    [geert] Rebased
    [geert] Reworded
    [geert] Dropped .rx_chunk, as it's always identical to .rx_buf[0]
    Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    7b39d901
sh-sci.c 64.9 KB