CVE-2026-99449: usb: gadget: fix refcount underflow in gadgetfs_bind() error path
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: fix refcount underflow in gadgetfsbind() error path
gadgetfsbind() calls getdev() only on the success path, but gadgetfsunbind() called from the enomem error label unconditionally calls putdev(). When bind fails (e.g. ENOMEM), putdev() fires without a matching getdev(), leaving the refcount unbalanced.
A subsequent close of the ep0 file descriptor calls devrelease() -> putdev() which hits zero and frees the object; then gadgetfskillsb() calls putdev(thedevice) again on the already-freed pointer, triggering a refcount underflow and use-after-free.
Fix by calling getdev() at the start of gadgetfsbind(), before any error path that invokes gadgetfsunbind(), so the reference is always balanced regardless of whether bind succeeds or fails.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.117 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.61 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.2 - Compensating control
Call get_dev() at the start of gadgetfs_bind(), before any error path can call put_dev(), so the reference is balanced whether bind succeeds or fails.