{"id":"CVE-2025-40314","summary":"usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nusb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget\n\nIn the __cdnsp_gadget_init() and cdnsp_gadget_exit() functions, the gadget\nstructure (pdev-\u003egadget) was freed before its endpoints.\nThe endpoints are linked via the ep_list in the gadget structure.\nFreeing the gadget first leaves dangling pointers in the endpoint list.\nWhen the endpoints are subsequently freed, this results in a use-after-free.\n\nFix:\nBy separating the usb_del_gadget_udc() operation into distinct \"del\" and\n\"put\" steps, cdnsp_gadget_free_endpoints() can be executed prior to the\nfinal release of the gadget structure with usb_put_gadget().\n\nA patch similar to bb9c74a5bd14(\"usb: dwc3: gadget: Free gadget structure\n only after freeing endpoints\").","modified":"2026-04-02T12:48:21.976658Z","published":"2025-12-08T00:46:40.576Z","related":["MGASA-2026-0017","MGASA-2026-0018","SUSE-SU-2026:0278-1","SUSE-SU-2026:0281-1","SUSE-SU-2026:0293-1","SUSE-SU-2026:0315-1","SUSE-SU-2026:20207-1","SUSE-SU-2026:20220-1","SUSE-SU-2026:20228-1","SUSE-SU-2026:20477-1","SUSE-SU-2026:20498-1","SUSE-SU-2026:20845-1","SUSE-SU-2026:20876-1","openSUSE-SU-2026:20145-1"],"database_specific":{"cna_assigner":"Linux","osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/40xxx/CVE-2025-40314.json"},"references":[{"type":"WEB","url":"https://git.kernel.org/stable/c/0cf9a50af91fbdac3849f8d950e883a3eaa3ecea"},{"type":"WEB","url":"https://git.kernel.org/stable/c/37158ce6ba964b62d1e3eebd11f03c6900a52dd1"},{"type":"WEB","url":"https://git.kernel.org/stable/c/87c5ff5615dc0a37167e8faf3adeeddc6f1344a3"},{"type":"WEB","url":"https://git.kernel.org/stable/c/9c52f01429c377a2d32cafc977465f37b5384f77"},{"type":"WEB","url":"https://git.kernel.org/stable/c/ea37884097a0931abb8e11e40eacfb25e9fdb5e9"},{"type":"WEB","url":"https://git.kernel.org/stable/c/fdf573c517627a96f5040f988e9b21267806be5c"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/40xxx/CVE-2025-40314.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-40314"},{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"8bc1901ca7b07d864fca11461b3875b31f949765"},{"fixed":"0cf9a50af91fbdac3849f8d950e883a3eaa3ecea"},{"fixed":"37158ce6ba964b62d1e3eebd11f03c6900a52dd1"},{"fixed":"ea37884097a0931abb8e11e40eacfb25e9fdb5e9"},{"fixed":"9c52f01429c377a2d32cafc977465f37b5384f77"},{"fixed":"fdf573c517627a96f5040f988e9b21267806be5c"},{"fixed":"87c5ff5615dc0a37167e8faf3adeeddc6f1344a3"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-40314.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"5.3.0"},{"fixed":"5.15.197"}]},{"type":"ECOSYSTEM","events":[{"introduced":"5.16.0"},{"fixed":"6.1.159"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.2.0"},{"fixed":"6.6.117"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.7.0"},{"fixed":"6.12.58"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.13.0"},{"fixed":"6.17.8"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-40314.json"}}],"schema_version":"1.7.5"}