From: Greg Kroah-Hartman Date: Mon, 13 Jan 2025 10:31:14 +0000 (+0100) Subject: 6.1-stable patches X-Git-Tag: v6.1.125~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e9cd50bed59e4de972a8b265b1dc5005ae2f4338;p=thirdparty%2Fkernel%2Fstable-queue.git 6.1-stable patches added patches: misc-microchip-pci1xxxx-resolve-kernel-panic-during-gpio-irq-handling.patch misc-microchip-pci1xxxx-resolve-return-code-mismatch-during-gpio-set-config.patch topology-keep-the-cpumask-unchanged-when-printing-cpumap.patch usb-core-disable-lpm-only-for-non-suspended-ports.patch usb-dwc3-am62-disable-autosuspend-during-remove.patch usb-fix-reference-leak-in-usb_new_device.patch usb-gadget-f_fs-remove-warn_on-in-functionfs_bind.patch usb-gadget-f_uac2-fix-incorrect-setting-of-bnumendpoints.patch usb-gadget-u_serial-disable-ep-before-setting-port-to-null-to-fix-the-crash-caused-by-port-being-null.patch usb-usblp-return-error-when-setting-unsupported-protocol.patch --- diff --git a/queue-6.1/misc-microchip-pci1xxxx-resolve-kernel-panic-during-gpio-irq-handling.patch b/queue-6.1/misc-microchip-pci1xxxx-resolve-kernel-panic-during-gpio-irq-handling.patch new file mode 100644 index 00000000000..2b0e9956d36 --- /dev/null +++ b/queue-6.1/misc-microchip-pci1xxxx-resolve-kernel-panic-during-gpio-irq-handling.patch @@ -0,0 +1,33 @@ +From 194f9f94a5169547d682e9bbcc5ae6d18a564735 Mon Sep 17 00:00:00 2001 +From: Rengarajan S +Date: Thu, 5 Dec 2024 19:06:25 +0530 +Subject: misc: microchip: pci1xxxx: Resolve kernel panic during GPIO IRQ handling + +From: Rengarajan S + +commit 194f9f94a5169547d682e9bbcc5ae6d18a564735 upstream. + +Resolve kernel panic caused by improper handling of IRQs while +accessing GPIO values. This is done by replacing generic_handle_irq with +handle_nested_irq. + +Fixes: 1f4d8ae231f4 ("misc: microchip: pci1xxxx: Add gpio irq handler and irq helper functions irq_ack, irq_mask, irq_unmask and irq_set_type of irq_chip.") +Cc: stable +Signed-off-by: Rengarajan S +Link: https://lore.kernel.org/r/20241205133626.1483499-2-rengarajan.s@microchip.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c ++++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c +@@ -273,7 +273,7 @@ static irqreturn_t pci1xxxx_gpio_irq_han + writel(BIT(bit), priv->reg_base + INTR_STATUS_OFFSET(gpiobank)); + spin_unlock_irqrestore(&priv->lock, flags); + irq = irq_find_mapping(gc->irq.domain, (bit + (gpiobank * 32))); +- generic_handle_irq(irq); ++ handle_nested_irq(irq); + } + } + spin_lock_irqsave(&priv->lock, flags); diff --git a/queue-6.1/misc-microchip-pci1xxxx-resolve-return-code-mismatch-during-gpio-set-config.patch b/queue-6.1/misc-microchip-pci1xxxx-resolve-return-code-mismatch-during-gpio-set-config.patch new file mode 100644 index 00000000000..e8b03141069 --- /dev/null +++ b/queue-6.1/misc-microchip-pci1xxxx-resolve-return-code-mismatch-during-gpio-set-config.patch @@ -0,0 +1,34 @@ +From c7a5378a0f707686de3ddb489f1653c523bb7dcc Mon Sep 17 00:00:00 2001 +From: Rengarajan S +Date: Thu, 5 Dec 2024 19:06:26 +0530 +Subject: misc: microchip: pci1xxxx: Resolve return code mismatch during GPIO set config + +From: Rengarajan S + +commit c7a5378a0f707686de3ddb489f1653c523bb7dcc upstream. + +Driver returns -EOPNOTSUPPORTED on unsupported parameters case in set +config. Upper level driver checks for -ENOTSUPP. Because of the return +code mismatch, the ioctls from userspace fail. Resolve the issue by +passing -ENOTSUPP during unsupported case. + +Fixes: 7d3e4d807df2 ("misc: microchip: pci1xxxx: load gpio driver for the gpio controller auxiliary device enumerated by the auxiliary bus driver.") +Cc: stable +Signed-off-by: Rengarajan S +Link: https://lore.kernel.org/r/20241205133626.1483499-3-rengarajan.s@microchip.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c ++++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c +@@ -148,7 +148,7 @@ static int pci1xxxx_gpio_set_config(stru + pci1xxx_assign_bit(priv->reg_base, OPENDRAIN_OFFSET(offset), (offset % 32), true); + break; + default: +- ret = -EOPNOTSUPP; ++ ret = -ENOTSUPP; + break; + } + spin_unlock_irqrestore(&priv->lock, flags); diff --git a/queue-6.1/series b/queue-6.1/series index d5132df7207..fb2e0eba0a0 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -60,3 +60,13 @@ staging-iio-ad9832-correct-phase-range-check.patch usb-storage-add-max-sectors-quirk-for-nokia-208.patch usb-serial-cp210x-add-phoenix-contact-ups-device.patch usb-dwc3-gadget-fix-writing-nyet-threshold.patch +topology-keep-the-cpumask-unchanged-when-printing-cpumap.patch +misc-microchip-pci1xxxx-resolve-kernel-panic-during-gpio-irq-handling.patch +misc-microchip-pci1xxxx-resolve-return-code-mismatch-during-gpio-set-config.patch +usb-gadget-u_serial-disable-ep-before-setting-port-to-null-to-fix-the-crash-caused-by-port-being-null.patch +usb-dwc3-am62-disable-autosuspend-during-remove.patch +usb-usblp-return-error-when-setting-unsupported-protocol.patch +usb-core-disable-lpm-only-for-non-suspended-ports.patch +usb-fix-reference-leak-in-usb_new_device.patch +usb-gadget-f_uac2-fix-incorrect-setting-of-bnumendpoints.patch +usb-gadget-f_fs-remove-warn_on-in-functionfs_bind.patch diff --git a/queue-6.1/topology-keep-the-cpumask-unchanged-when-printing-cpumap.patch b/queue-6.1/topology-keep-the-cpumask-unchanged-when-printing-cpumap.patch new file mode 100644 index 00000000000..441b076e3e0 --- /dev/null +++ b/queue-6.1/topology-keep-the-cpumask-unchanged-when-printing-cpumap.patch @@ -0,0 +1,100 @@ +From cbd399f78e23ad4492c174fc5e6b3676dba74a52 Mon Sep 17 00:00:00 2001 +From: Li Huafei +Date: Thu, 14 Nov 2024 19:01:41 +0800 +Subject: topology: Keep the cpumask unchanged when printing cpumap + +From: Li Huafei + +commit cbd399f78e23ad4492c174fc5e6b3676dba74a52 upstream. + +During fuzz testing, the following warning was discovered: + + different return values (15 and 11) from vsnprintf("%*pbl + ", ...) + + test:keyward is WARNING in kvasprintf + WARNING: CPU: 55 PID: 1168477 at lib/kasprintf.c:30 kvasprintf+0x121/0x130 + Call Trace: + kvasprintf+0x121/0x130 + kasprintf+0xa6/0xe0 + bitmap_print_to_buf+0x89/0x100 + core_siblings_list_read+0x7e/0xb0 + kernfs_file_read_iter+0x15b/0x270 + new_sync_read+0x153/0x260 + vfs_read+0x215/0x290 + ksys_read+0xb9/0x160 + do_syscall_64+0x56/0x100 + entry_SYSCALL_64_after_hwframe+0x78/0xe2 + +The call trace shows that kvasprintf() reported this warning during the +printing of core_siblings_list. kvasprintf() has several steps: + + (1) First, calculate the length of the resulting formatted string. + + (2) Allocate a buffer based on the returned length. + + (3) Then, perform the actual string formatting. + + (4) Check whether the lengths of the formatted strings returned in + steps (1) and (2) are consistent. + +If the core_cpumask is modified between steps (1) and (3), the lengths +obtained in these two steps may not match. Indeed our test includes cpu +hotplugging, which should modify core_cpumask while printing. + +To fix this issue, cache the cpumask into a temporary variable before +calling cpumap_print_{list, cpumask}_to_buf(), to keep it unchanged +during the printing process. + +Fixes: bb9ec13d156e ("topology: use bin_attribute to break the size limitation of cpumap ABI") +Cc: stable +Signed-off-by: Li Huafei +Reviewed-by: Jonathan Cameron +Link: https://lore.kernel.org/r/20241114110141.94725-1-lihuafei1@huawei.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/base/topology.c | 24 ++++++++++++++++++++---- + 1 file changed, 20 insertions(+), 4 deletions(-) + +--- a/drivers/base/topology.c ++++ b/drivers/base/topology.c +@@ -27,9 +27,17 @@ static ssize_t name##_read(struct file * + loff_t off, size_t count) \ + { \ + struct device *dev = kobj_to_dev(kobj); \ ++ cpumask_var_t mask; \ ++ ssize_t n; \ + \ +- return cpumap_print_bitmask_to_buf(buf, topology_##mask(dev->id), \ +- off, count); \ ++ if (!alloc_cpumask_var(&mask, GFP_KERNEL)) \ ++ return -ENOMEM; \ ++ \ ++ cpumask_copy(mask, topology_##mask(dev->id)); \ ++ n = cpumap_print_bitmask_to_buf(buf, mask, off, count); \ ++ free_cpumask_var(mask); \ ++ \ ++ return n; \ + } \ + \ + static ssize_t name##_list_read(struct file *file, struct kobject *kobj, \ +@@ -37,9 +45,17 @@ static ssize_t name##_list_read(struct f + loff_t off, size_t count) \ + { \ + struct device *dev = kobj_to_dev(kobj); \ ++ cpumask_var_t mask; \ ++ ssize_t n; \ ++ \ ++ if (!alloc_cpumask_var(&mask, GFP_KERNEL)) \ ++ return -ENOMEM; \ ++ \ ++ cpumask_copy(mask, topology_##mask(dev->id)); \ ++ n = cpumap_print_list_to_buf(buf, mask, off, count); \ ++ free_cpumask_var(mask); \ + \ +- return cpumap_print_list_to_buf(buf, topology_##mask(dev->id), \ +- off, count); \ ++ return n; \ + } + + define_id_show_func(physical_package_id, "%d"); diff --git a/queue-6.1/usb-core-disable-lpm-only-for-non-suspended-ports.patch b/queue-6.1/usb-core-disable-lpm-only-for-non-suspended-ports.patch new file mode 100644 index 00000000000..99b3ee78c94 --- /dev/null +++ b/queue-6.1/usb-core-disable-lpm-only-for-non-suspended-ports.patch @@ -0,0 +1,52 @@ +From 59bfeaf5454b7e764288d84802577f4a99bf0819 Mon Sep 17 00:00:00 2001 +From: Kai-Heng Feng +Date: Fri, 6 Dec 2024 15:48:17 +0800 +Subject: USB: core: Disable LPM only for non-suspended ports + +From: Kai-Heng Feng + +commit 59bfeaf5454b7e764288d84802577f4a99bf0819 upstream. + +There's USB error when tegra board is shutting down: +[ 180.919315] usb 2-3: Failed to set U1 timeout to 0x0,error code -113 +[ 180.919995] usb 2-3: Failed to set U1 timeout to 0xa,error code -113 +[ 180.920512] usb 2-3: Failed to set U2 timeout to 0x4,error code -113 +[ 186.157172] tegra-xusb 3610000.usb: xHCI host controller not responding, assume dead +[ 186.157858] tegra-xusb 3610000.usb: HC died; cleaning up +[ 186.317280] tegra-xusb 3610000.usb: Timeout while waiting for evaluate context command + +The issue is caused by disabling LPM on already suspended ports. + +For USB2 LPM, the LPM is already disabled during port suspend. For USB3 +LPM, port won't transit to U1/U2 when it's already suspended in U3, +hence disabling LPM is only needed for ports that are not suspended. + +Cc: Wayne Chang +Cc: stable +Fixes: d920a2ed8620 ("usb: Disable USB3 LPM at shutdown") +Signed-off-by: Kai-Heng Feng +Acked-by: Alan Stern +Tested-by: Jon Hunter +Link: https://lore.kernel.org/r/20241206074817.89189-1-kaihengf@nvidia.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/core/port.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/usb/core/port.c ++++ b/drivers/usb/core/port.c +@@ -412,10 +412,11 @@ static int usb_port_runtime_suspend(stru + static void usb_port_shutdown(struct device *dev) + { + struct usb_port *port_dev = to_usb_port(dev); ++ struct usb_device *udev = port_dev->child; + +- if (port_dev->child) { +- usb_disable_usb2_hardware_lpm(port_dev->child); +- usb_unlocked_disable_lpm(port_dev->child); ++ if (udev && !udev->port_is_suspended) { ++ usb_disable_usb2_hardware_lpm(udev); ++ usb_unlocked_disable_lpm(udev); + } + } + diff --git a/queue-6.1/usb-dwc3-am62-disable-autosuspend-during-remove.patch b/queue-6.1/usb-dwc3-am62-disable-autosuspend-during-remove.patch new file mode 100644 index 00000000000..e1c2614464e --- /dev/null +++ b/queue-6.1/usb-dwc3-am62-disable-autosuspend-during-remove.patch @@ -0,0 +1,35 @@ +From 625e70ccb7bbbb2cc912e23c63390946170c085c Mon Sep 17 00:00:00 2001 +From: Prashanth K +Date: Mon, 9 Dec 2024 16:27:28 +0530 +Subject: usb: dwc3-am62: Disable autosuspend during remove + +From: Prashanth K + +commit 625e70ccb7bbbb2cc912e23c63390946170c085c upstream. + +Runtime PM documentation (Section 5) mentions, during remove() +callbacks, drivers should undo the runtime PM changes done in +probe(). Usually this means calling pm_runtime_disable(), +pm_runtime_dont_use_autosuspend() etc. Hence add missing +function to disable autosuspend on dwc3-am62 driver unbind. + +Fixes: e8784c0aec03 ("drivers: usb: dwc3: Add AM62 USB wrapper driver") +Cc: stable +Signed-off-by: Prashanth K +Acked-by: Thinh Nguyen +Link: https://lore.kernel.org/r/20241209105728.3216872-1-quic_prashk@quicinc.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/dwc3/dwc3-am62.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/usb/dwc3/dwc3-am62.c ++++ b/drivers/usb/dwc3/dwc3-am62.c +@@ -263,6 +263,7 @@ static int dwc3_ti_remove(struct platfor + + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); ++ pm_runtime_dont_use_autosuspend(dev); + pm_runtime_set_suspended(dev); + + platform_set_drvdata(pdev, NULL); diff --git a/queue-6.1/usb-fix-reference-leak-in-usb_new_device.patch b/queue-6.1/usb-fix-reference-leak-in-usb_new_device.patch new file mode 100644 index 00000000000..c5f25e476b0 --- /dev/null +++ b/queue-6.1/usb-fix-reference-leak-in-usb_new_device.patch @@ -0,0 +1,54 @@ +From 0df11fa8cee5a9cf8753d4e2672bb3667138c652 Mon Sep 17 00:00:00 2001 +From: Ma Ke +Date: Wed, 18 Dec 2024 15:13:46 +0800 +Subject: usb: fix reference leak in usb_new_device() + +From: Ma Ke + +commit 0df11fa8cee5a9cf8753d4e2672bb3667138c652 upstream. + +When device_add(&udev->dev) succeeds and a later call fails, +usb_new_device() does not properly call device_del(). As comment of +device_add() says, 'if device_add() succeeds, you should call +device_del() when you want to get rid of it. If device_add() has not +succeeded, use only put_device() to drop the reference count'. + +Found by code review. + +Cc: stable +Fixes: 9f8b17e643fe ("USB: make usbdevices export their device nodes instead of using a separate class") +Signed-off-by: Ma Ke +Reviewed-by: Alan Stern +Link: https://lore.kernel.org/r/20241218071346.2973980-1-make_ruc2021@163.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/core/hub.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -2632,13 +2632,13 @@ int usb_new_device(struct usb_device *ud + err = sysfs_create_link(&udev->dev.kobj, + &port_dev->dev.kobj, "port"); + if (err) +- goto fail; ++ goto out_del_dev; + + err = sysfs_create_link(&port_dev->dev.kobj, + &udev->dev.kobj, "device"); + if (err) { + sysfs_remove_link(&udev->dev.kobj, "port"); +- goto fail; ++ goto out_del_dev; + } + + if (!test_and_set_bit(port1, hub->child_usage_bits)) +@@ -2650,6 +2650,8 @@ int usb_new_device(struct usb_device *ud + pm_runtime_put_sync_autosuspend(&udev->dev); + return err; + ++out_del_dev: ++ device_del(&udev->dev); + fail: + usb_set_device_state(udev, USB_STATE_NOTATTACHED); + pm_runtime_disable(&udev->dev); diff --git a/queue-6.1/usb-gadget-f_fs-remove-warn_on-in-functionfs_bind.patch b/queue-6.1/usb-gadget-f_fs-remove-warn_on-in-functionfs_bind.patch new file mode 100644 index 00000000000..caefd95a4c0 --- /dev/null +++ b/queue-6.1/usb-gadget-f_fs-remove-warn_on-in-functionfs_bind.patch @@ -0,0 +1,75 @@ +From dfc51e48bca475bbee984e90f33fdc537ce09699 Mon Sep 17 00:00:00 2001 +From: Akash M +Date: Thu, 19 Dec 2024 18:22:19 +0530 +Subject: usb: gadget: f_fs: Remove WARN_ON in functionfs_bind + +From: Akash M + +commit dfc51e48bca475bbee984e90f33fdc537ce09699 upstream. + +This commit addresses an issue related to below kernel panic where +panic_on_warn is enabled. It is caused by the unnecessary use of WARN_ON +in functionsfs_bind, which easily leads to the following scenarios. + +1.adb_write in adbd 2. UDC write via configfs + ================= ===================== + +->usb_ffs_open_thread() ->UDC write + ->open_functionfs() ->configfs_write_iter() + ->adb_open() ->gadget_dev_desc_UDC_store() + ->adb_write() ->usb_gadget_register_driver_owner + ->driver_register() +->StartMonitor() ->bus_add_driver() + ->adb_read() ->gadget_bind_driver() + ->configfs_composite_bind() + ->usb_add_function() +->open_functionfs() ->ffs_func_bind() + ->adb_open() ->functionfs_bind() + state !=FFS_ACTIVE> + +The adb_open, adb_read, and adb_write operations are invoked from the +daemon, but trying to bind the function is a process that is invoked by +UDC write through configfs, which opens up the possibility of a race +condition between the two paths. In this race scenario, the kernel panic +occurs due to the WARN_ON from functionfs_bind when panic_on_warn is +enabled. This commit fixes the kernel panic by removing the unnecessary +WARN_ON. + +Kernel panic - not syncing: kernel: panic_on_warn set ... +[ 14.542395] Call trace: +[ 14.542464] ffs_func_bind+0x1c8/0x14a8 +[ 14.542468] usb_add_function+0xcc/0x1f0 +[ 14.542473] configfs_composite_bind+0x468/0x588 +[ 14.542478] gadget_bind_driver+0x108/0x27c +[ 14.542483] really_probe+0x190/0x374 +[ 14.542488] __driver_probe_device+0xa0/0x12c +[ 14.542492] driver_probe_device+0x3c/0x220 +[ 14.542498] __driver_attach+0x11c/0x1fc +[ 14.542502] bus_for_each_dev+0x104/0x160 +[ 14.542506] driver_attach+0x24/0x34 +[ 14.542510] bus_add_driver+0x154/0x270 +[ 14.542514] driver_register+0x68/0x104 +[ 14.542518] usb_gadget_register_driver_owner+0x48/0xf4 +[ 14.542523] gadget_dev_desc_UDC_store+0xf8/0x144 +[ 14.542526] configfs_write_iter+0xf0/0x138 + +Fixes: ddf8abd25994 ("USB: f_fs: the FunctionFS driver") +Cc: stable +Signed-off-by: Akash M +Link: https://lore.kernel.org/r/20241219125221.1679-1-akash.m5@samsung.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/gadget/function/f_fs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/usb/gadget/function/f_fs.c ++++ b/drivers/usb/gadget/function/f_fs.c +@@ -1868,7 +1868,7 @@ static int functionfs_bind(struct ffs_da + + ENTER(); + +- if (WARN_ON(ffs->state != FFS_ACTIVE ++ if ((ffs->state != FFS_ACTIVE + || test_and_set_bit(FFS_FL_BOUND, &ffs->flags))) + return -EBADFD; + diff --git a/queue-6.1/usb-gadget-f_uac2-fix-incorrect-setting-of-bnumendpoints.patch b/queue-6.1/usb-gadget-f_uac2-fix-incorrect-setting-of-bnumendpoints.patch new file mode 100644 index 00000000000..3ab86eb9a6b --- /dev/null +++ b/queue-6.1/usb-gadget-f_uac2-fix-incorrect-setting-of-bnumendpoints.patch @@ -0,0 +1,36 @@ +From 057bd54dfcf68b1f67e6dfc32a47a72e12198495 Mon Sep 17 00:00:00 2001 +From: Prashanth K +Date: Wed, 11 Dec 2024 17:29:15 +0530 +Subject: usb: gadget: f_uac2: Fix incorrect setting of bNumEndpoints + +From: Prashanth K + +commit 057bd54dfcf68b1f67e6dfc32a47a72e12198495 upstream. + +Currently afunc_bind sets std_ac_if_desc.bNumEndpoints to 1 if +controls (mute/volume) are enabled. During next afunc_bind call, +bNumEndpoints would be unchanged and incorrectly set to 1 even +if the controls aren't enabled. + +Fix this by resetting the value of bNumEndpoints to 0 on every +afunc_bind call. + +Fixes: eaf6cbe09920 ("usb: gadget: f_uac2: add volume and mute support") +Cc: stable +Signed-off-by: Prashanth K +Link: https://lore.kernel.org/r/20241211115915.159864-1-quic_prashk@quicinc.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/gadget/function/f_uac2.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/usb/gadget/function/f_uac2.c ++++ b/drivers/usb/gadget/function/f_uac2.c +@@ -1176,6 +1176,7 @@ afunc_bind(struct usb_configuration *cfg + uac2->as_in_alt = 0; + } + ++ std_ac_if_desc.bNumEndpoints = 0; + if (FUOUT_EN(uac2_opts) || FUIN_EN(uac2_opts)) { + uac2->int_ep = usb_ep_autoconfig(gadget, &fs_ep_int_desc); + if (!uac2->int_ep) { diff --git a/queue-6.1/usb-gadget-u_serial-disable-ep-before-setting-port-to-null-to-fix-the-crash-caused-by-port-being-null.patch b/queue-6.1/usb-gadget-u_serial-disable-ep-before-setting-port-to-null-to-fix-the-crash-caused-by-port-being-null.patch new file mode 100644 index 00000000000..e4a37888ffa --- /dev/null +++ b/queue-6.1/usb-gadget-u_serial-disable-ep-before-setting-port-to-null-to-fix-the-crash-caused-by-port-being-null.patch @@ -0,0 +1,69 @@ +From 13014969cbf07f18d62ceea40bd8ca8ec9d36cec Mon Sep 17 00:00:00 2001 +From: Lianqin Hu +Date: Tue, 17 Dec 2024 07:58:44 +0000 +Subject: usb: gadget: u_serial: Disable ep before setting port to null to fix the crash caused by port being null + +From: Lianqin Hu + +commit 13014969cbf07f18d62ceea40bd8ca8ec9d36cec upstream. + +Considering that in some extreme cases, when performing the +unbinding operation, gserial_disconnect has cleared gser->ioport, +which triggers gadget reconfiguration, and then calls gs_read_complete, +resulting in access to a null pointer. Therefore, ep is disabled before +gserial_disconnect sets port to null to prevent this from happening. + +Call trace: + gs_read_complete+0x58/0x240 + usb_gadget_giveback_request+0x40/0x160 + dwc3_remove_requests+0x170/0x484 + dwc3_ep0_out_start+0xb0/0x1d4 + __dwc3_gadget_start+0x25c/0x720 + kretprobe_trampoline.cfi_jt+0x0/0x8 + kretprobe_trampoline.cfi_jt+0x0/0x8 + udc_bind_to_driver+0x1d8/0x300 + usb_gadget_probe_driver+0xa8/0x1dc + gadget_dev_desc_UDC_store+0x13c/0x188 + configfs_write_iter+0x160/0x1f4 + vfs_write+0x2d0/0x40c + ksys_write+0x7c/0xf0 + __arm64_sys_write+0x20/0x30 + invoke_syscall+0x60/0x150 + el0_svc_common+0x8c/0xf8 + do_el0_svc+0x28/0xa0 + el0_svc+0x24/0x84 + +Fixes: c1dca562be8a ("usb gadget: split out serial core") +Cc: stable +Suggested-by: Greg Kroah-Hartman +Signed-off-by: Lianqin Hu +Link: https://lore.kernel.org/r/TYUPR06MB621733B5AC690DBDF80A0DCCD2042@TYUPR06MB6217.apcprd06.prod.outlook.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/gadget/function/u_serial.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/drivers/usb/gadget/function/u_serial.c ++++ b/drivers/usb/gadget/function/u_serial.c +@@ -1393,6 +1393,10 @@ void gserial_disconnect(struct gserial * + /* REVISIT as above: how best to track this? */ + port->port_line_coding = gser->port_line_coding; + ++ /* disable endpoints, aborting down any active I/O */ ++ usb_ep_disable(gser->out); ++ usb_ep_disable(gser->in); ++ + port->port_usb = NULL; + gser->ioport = NULL; + if (port->port.count > 0) { +@@ -1404,10 +1408,6 @@ void gserial_disconnect(struct gserial * + spin_unlock(&port->port_lock); + spin_unlock_irqrestore(&serial_port_lock, flags); + +- /* disable endpoints, aborting down any active I/O */ +- usb_ep_disable(gser->out); +- usb_ep_disable(gser->in); +- + /* finally, free any unused/unusable I/O buffers */ + spin_lock_irqsave(&port->port_lock, flags); + if (port->port.count == 0) diff --git a/queue-6.1/usb-usblp-return-error-when-setting-unsupported-protocol.patch b/queue-6.1/usb-usblp-return-error-when-setting-unsupported-protocol.patch new file mode 100644 index 00000000000..475362b9e20 --- /dev/null +++ b/queue-6.1/usb-usblp-return-error-when-setting-unsupported-protocol.patch @@ -0,0 +1,43 @@ +From 7a3d76a0b60b3f6fc3375e4de2174bab43f64545 Mon Sep 17 00:00:00 2001 +From: Jun Yan +Date: Thu, 12 Dec 2024 22:38:52 +0800 +Subject: USB: usblp: return error when setting unsupported protocol + +From: Jun Yan + +commit 7a3d76a0b60b3f6fc3375e4de2174bab43f64545 upstream. + +Fix the regression introduced by commit d8c6edfa3f4e ("USB: +usblp: don't call usb_set_interface if there's a single alt"), +which causes that unsupported protocols can also be set via +ioctl when the num_altsetting of the device is 1. + +Move the check for protocol support to the earlier stage. + +Fixes: d8c6edfa3f4e ("USB: usblp: don't call usb_set_interface if there's a single alt") +Cc: stable +Signed-off-by: Jun Yan +Link: https://lore.kernel.org/r/20241212143852.671889-1-jerrysteve1101@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/class/usblp.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/usb/class/usblp.c ++++ b/drivers/usb/class/usblp.c +@@ -1337,11 +1337,12 @@ static int usblp_set_protocol(struct usb + if (protocol < USBLP_FIRST_PROTOCOL || protocol > USBLP_LAST_PROTOCOL) + return -EINVAL; + ++ alts = usblp->protocol[protocol].alt_setting; ++ if (alts < 0) ++ return -EINVAL; ++ + /* Don't unnecessarily set the interface if there's a single alt. */ + if (usblp->intf->num_altsetting > 1) { +- alts = usblp->protocol[protocol].alt_setting; +- if (alts < 0) +- return -EINVAL; + r = usb_set_interface(usblp->dev, usblp->ifnum, alts); + if (r < 0) { + printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",