# CVE-2021-47272: linux: In the Linux kernel, the following vulnerability has been resolved:  usb: dwc3: gadget: Bail from dwc3_gadget_exit()...

CVE-2021-47272 is fixed in linux on 1 platform, first by DEBIAN-CVE-2021-47272, released May 21, 2024. It is not reported as exploited. Patch Radar priority: Routine.

- Web page: https://patchblox.com/security/cve/CVE-2021-47272
- Priority: Routine
- CVSS: 5.5 (medium)
- EPSS: 0.0022
- CISA KEV: not listed
- Exploited (vendor report): no
- Publicly disclosed: no
- Published: May 21, 2024

## Description

In the Linux kernel, the following vulnerability has been resolved:  usb: dwc3: gadget: Bail from dwc3_gadget_exit() if dwc->gadget is NULL  There exists a possible scenario in which dwc3_gadget_init() can fail: during during host -> peripheral mode switch in dwc3_set_mode(), and a pending gadget driver fails to bind.  Then, if the DRD undergoes another mode switch from peripheral->host the resulting dwc3_gadget_exit() will attempt to reference an invalid and dangling dwc->gadget pointer as well as call dma_free_coherent() on unmapped DMA pointers.  The exact scenario can be reproduced as follows:  - Start DWC3 in peripheral mode  - Configure ConfigFS gadget with FunctionFS instance (or use g_ffs)  - Run FunctionFS userspace application (open EPs, write descriptors, etc)  - Bind gadget driver to DWC3's UDC  - Switch DWC3 to host mode    => dwc3_gadget_exit() is called. usb_del_gadget() will put the 	ConfigFS driver instance on the gadget_driver_pending_list  - Stop FunctionFS application (closes the ep files)  - Switch DWC3 to peripheral mode    => dwc3_gadget_init() fails as usb_add_gadget() calls 	check_pending_gadget_drivers() and attempts to rebind the UDC 	to the ConfigFS gadget but fails with -19 (-ENODEV) because the 	FFS instance is not in FFS_ACTIVE state (userspace has not 	re-opened and written the descriptors yet, i.e. desc_ready!=0).  - Switch DWC3 back to host mode    => dwc3_gadget_exit() is called again, but this time dwc->gadget 	is invalid.  Although it can be argued that userspace should take responsibility for ensuring that the FunctionFS application be ready prior to allowing the composite driver bind to the UDC, failure to do so should not result in a panic from the kernel driver.  Fix this by setting dwc->gadget to NULL in the failure path of dwc3_gadget_init() and add a check to dwc3_gadget_exit() to bail out unless the gadget pointer is valid.

## Where it's fixed

| Platform | Product | Fixed in | Fix | Released |
|---|---|---|---|---|
| Linux | linux Debian 12.15 (bookworm) | 5.10.46-1 | [DEBIAN-CVE-2021-47272](https://patchblox.com/security/data/fix/linux/debian-cve-2021-47272.md) | May 21, 2024 |
| Linux | linux Debian 13.5 (trixie) | 5.10.46-1 | [DEBIAN-CVE-2021-47272](https://patchblox.com/security/data/fix/linux/debian-cve-2021-47272.md) | May 21, 2024 |
| Linux | linux Debian 14 | 5.10.46-1 | [DEBIAN-CVE-2021-47272](https://patchblox.com/security/data/fix/linux/debian-cve-2021-47272.md) | May 21, 2024 |

---

Data as of 2026-11-09T01:18:40Z UTC. Source: Patchblox Patch Radar (https://patchblox.com/security/patch-radar). Patchblox finds out-of-date software on Windows, macOS and Linux and updates it through release rings: https://patchblox.com/demo

Free to use with attribution: show "Data: Patchblox Patch Radar" with a link to https://patchblox.com/security/patch-radar. Terms, including what needs a written agreement: https://patchblox.com/security/patch-radar/use-the-data

Product names, logos and trademarks shown on Patch Radar belong to their respective owners. They are used only to identify the software each security fix applies to and to help readers find their platform. Their use does not imply any affiliation with, or endorsement by, those owners, and Patchblox is not affiliated with any of them.
