linux/drivers/usb/core
Ruihan Li d0b861653f usb: usbfs: Use consistent mmap functions
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: a0e710a7de ("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>
2023-05-29 16:14:28 +01:00
..
buffer.c usb: usbfs: Enforce page requirements for mmap 2023-05-29 16:14:28 +01:00
config.c USB: core: Change configuration warnings to notices 2022-11-03 23:46:00 +09:00
devices.c usb: core: devices: drop redundant buffer overflow checks 2022-04-26 13:57:38 +02:00
devio.c usb: usbfs: Use consistent mmap functions 2023-05-29 16:14:28 +01:00
driver.c USB: mark all struct bus_type as const 2023-03-23 13:22:00 +01:00
endpoint.c usb: common: add function to get interval expressed in us unit 2021-03-10 09:37:17 +01:00
file.c driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
generic.c usb: core: Fix file path that does not exist 2021-12-05 14:24:19 +01:00
hcd-pci.c xhci: disable U3 suspended ports in S4 hibernate poweroff_late stage 2022-11-30 12:10:48 +01:00
hcd.c usb: core: hcd: Fix return value check in usb_hcd_setup_local_mem() 2022-11-29 08:56:09 +01:00
hub.c USB: core: Don't hold device lock while reading the "descriptors" sysfs file 2023-01-31 21:54:35 +01:00
hub.h usb: core: stop USB enumeration if too many retries 2022-11-08 16:50:21 +01:00
Kconfig USB: hub: Add Kconfig option to reduce number of port initialization retries 2020-10-02 11:29:02 +02:00
ledtrig-usbport.c
Makefile usb: misc: Add onboard_usb_hub driver 2022-07-08 14:53:50 +02:00
message.c USB: core: Fix docs warning caused by wireless_status feature 2023-04-06 17:14:14 +02:00
notify.c
of.c
otg_productlist.h
phy.c
phy.h
port.c usb: core: stop USB enumeration if too many retries 2022-11-08 16:50:21 +01:00
quirks.c usb: core: add quirk for Alcor Link AK9563 smartcard reader 2023-02-09 13:23:51 +01:00
sysfs.c USB: core: Add wireless_status sysfs attribute 2023-04-03 13:30:08 +02:00
urb.c kmsan: handle memory sent to/from USB 2022-10-03 14:03:22 -07:00
usb-acpi.c usb: acpi: Switch to use acpi_evaluate_dsm_typed() 2023-03-16 12:15:10 +01:00
usb.c USB: core: Add routines for endpoint checks in old drivers 2023-04-20 11:43:22 +02:00
usb.h Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00