linux/drivers/usb/core
Ruihan Li ac817e26f9 usb: usbfs: Use consistent mmap functions
commit d0b861653f 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: 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>
History 2023-06-14 11:13:07 +02:00
..
buffer.c usb: usbfs: Enforce page requirements for mmap 2023-06-14 11:13:07 +02:00
config.c usb: core: config: using bit mask instead of individual bits 2021-12-14 10:57:20 +01:00
devices.c usb: common: add function to get interval expressed in us unit 2021-03-10 09:37:17 +01:00
devio.c usb: usbfs: Use consistent mmap functions 2023-06-14 11:13:07 +02:00
driver.c USB: core: rename usb_driver_claim_interface() data parameter 2021-03-23 12:39:39 +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 USB: core: Fix races in character device registration and deregistraion 2019-08-12 22:47:24 +02:00
generic.c usbcore: Check both id_table and match() when both available 2020-10-28 13:24:58 +01:00
hcd-pci.c USB: hcd-pci: Fully suspend across freeze/thaw cycle 2022-06-14 18:36:21 +02:00
hcd.c USB: HCD: Fix URB giveback issue in tasklet function 2022-08-17 14:22:58 +02:00
hub.c USB: core: Don't hold device lock while reading the "descriptors" sysfs file 2023-03-03 11:45:54 +01:00
hub.h usb: core: reduce power-on-good delay time of root hub 2021-04-10 10:45:48 +02: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 usb: core: ledtrig-usbport: Demote obvious misuse of kerneldoc to standard comment blocks 2020-07-09 16:46:57 +02:00
Makefile usb: core: add a wrapper for the USB PHYs on the HCD 2018-03-09 09:43:53 -08:00
message.c USB: core: Avoid WARNings for 0-length descriptor requests 2021-06-09 11:11:39 +02:00
notify.c USB: core: Remove usbfs_mutex 2019-06-26 10:28:09 +08:00
of.c drivers: usb: Fix trivial spelling 2020-06-18 10:13:16 +02:00
otg_productlist.h USB: OTG: rename product list of devices 2020-06-19 08:58:55 +02:00
phy.c usb: core: phy: add support for PHY calibration 2019-09-03 15:54:55 +02:00
phy.h usb: core: phy: add support for PHY calibration 2019-09-03 15:54:55 +02:00
port.c Revert "usb: Link the ports to the connectors they are attached to" 2021-04-12 14:36:02 +02:00
quirks.c usb: core: add quirk for Alcor Link AK9563 smartcard reader 2023-02-14 19:18:03 +01:00
sysfs.c USB: core: Don't hold device lock while reading the "descriptors" sysfs file 2023-03-03 11:45:54 +01:00
urb.c USB: core: Fix hang in usb_kill_urb by adding memory barriers 2022-02-01 17:27:04 +01:00
usb-acpi.c usb: acpi: add helper to check port lpm capability using acpi _DSM 2023-01-24 07:22:44 +01:00
usb.c USB: core: Add routines for endpoint checks in old drivers 2023-05-30 13:55:31 +01:00
usb.h usbcore: Check both id_table and match() when both available 2020-10-28 13:24:58 +01:00