summary refs log tree commit diff
path: root/Documentation/riscv
diff options
context:
space:
mode:
authorRuihan Li <lrh2000@pku.edu.cn>2023-05-15 21:09:56 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-06-14 11:15:29 +0200
commit3901170529a70462c29798005f2e9b38bab211c5 (patch)
treec4784139f4730f258afe0310e8c8fef1cd5d3790 /Documentation/riscv
parent80e29f11be6932274370d66e28e6848ee1120033 (diff)
downloadlinux-3901170529a70462c29798005f2e9b38bab211c5.tar.gz
usb: usbfs: Use consistent mmap functions
commit d0b861653f8c16839c3035875b556afc4472f941 upstream.

When hcd->localmem_pool is non-null, localmem_pool is used to allocate
DMA memory. In this case, the dma address will be properly returned (in
dma_handle), and dma_mmap_coherent should be used to map this memory
into the user space. However, the current implementation uses
pfn_remap_range, which is supposed to map normal pages.

Instead of repeating the logic in the memory allocation function, this
patch introduces a more robust solution. Here, the type of allocated
memory is checked by testing whether dma_handle is properly set. If
dma_handle is properly returned, it means some DMA pages are allocated
and dma_mmap_coherent should be used to map them. Otherwise, normal
pages are allocated and pfn_remap_range should be called. This ensures
that the correct mmap functions are used consistently, independently
with logic details that determine which type of memory gets allocated.

Fixes: a0e710a7def4 ("USB: usbfs: fix mmap dma mismatch")
Cc: stable@vger.kernel.org
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
Link: https://lore.kernel.org/r/20230515130958.32471-3-lrh2000@pku.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'Documentation/riscv')
0 files changed, 0 insertions, 0 deletions