Skip to content
Heist/ feed
Back to feed
UnratedFix available

usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget

Type: advisorySources: OSV

In the Linux kernel, the following vulnerability has been resolved: usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget In the __cdnsp_gadget_init() and cdnsp_gadget_exit() functions, the gadget structure (pdev->gadget) was freed before its endpoints. The endpoints are linked via the ep_list in the gadget structure. Freeing the gadget first leaves dangling pointers in the endpoint list. When the endpoints are subsequently freed, this results in a use-after-free. Fix: By separating the usb_del_gadget_udc() operation into distinct "del" and "put" steps, cdnsp_gadget_free_endpoints() can be executed prior to the final release of the gadget structure with usb_put_gadget(). A patch similar to bb9c74a5bd14("usb: dwc3: gadget: Free gadget structure only after freeing endpoints").

Products
Kernel
Affected versions
Not specified
Fixed versions
5.15.197, 6.1.159, 6.12.58, 6.17.8, 6.6.117
CVEs
CVE-2025-40314
Confirmed fixed CVEs
Not specified
Updated in this feed
7 Nov 2026, 14:19 UTC · Revision 1

Source evidence

usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget

core-osv · Original source

Published 8 Dec 2025, 00:46 UTC

In the Linux kernel, the following vulnerability has been resolved: usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget In the __cdnsp_gadget_init() and cdnsp_gadget_exit() functions, the gadget structure (pdev->gadget) was freed before its endpoints. The endpoints are linked via the ep_list in the gadget structure. Freeing the gadget first leaves dangling pointers in the endpoint list. When the endpoints are subsequently freed, this results in a use-after-free. Fix: By separating the usb_del_gadget_udc() operation into distinct "del" and "put" steps, cdnsp_gadget_free_endpoints() can be executed prior to the final release of the gadget structure with usb_put_gadget(). A patch similar to bb9c74a5bd14("usb: dwc3: gadget: Free gadget structure only after freeing endpoints").

osv:CVE-2025-40314

Kernel

Fixed versions: 5.15.197, 6.1.159, 6.6.117, 6.12.58, 6.17.8

Complete source record
{
  "id": "7db8447a4a7f3bd82fe8e3a929b42b65c03a229080b608264cbffd6bea0a7b60",
  "url": "https://osv.dev/vulnerability/CVE-2025-40314",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget",
    "summary": "In the Linux kernel, the following vulnerability has been resolved: usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget In the __cdnsp_gadget_init() and cdnsp_gadget_exit() functions, the gadget structure (pdev->gadget) was freed before its endpoints. The endpoints are linked via the ep_list in the gadget structure. Freeing the gadget first leaves dangling pointers in the endpoint list. When the endpoints are subsequently freed, this results in a use-after-free. Fix: By separating the usb_del_gadget_udc() operation into distinct \"del\" and \"put\" steps, cdnsp_gadget_free_endpoints() can be executed prior to the final release of the gadget structure with usb_put_gadget(). A patch similar to bb9c74a5bd14(\"usb: dwc3: gadget: Free gadget structure only after freeing endpoints\").",
    "evidence": "osv:CVE-2025-40314",
    "products": [
      {
        "name": {
          "value": "Kernel",
          "evidence": "/affected/1/package/name"
        },
        "prerequisites": [],
        "fixed_versions": [
          {
            "value": "5.15.197",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.1.159",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.6.117",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.12.58",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.17.8",
            "evidence": "/affected/1/ranges"
          }
        ],
        "affected_versions": []
      }
    ],
    "severity": "unknown",
    "structured": {
      "id": "CVE-2025-40314",
      "aliases": [
        "CVE-2025-40314"
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
              "type": "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"
          }
        },
        {
          "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"
                }
              ]
            }
          ],
          "package": {
            "name": "Kernel",
            "ecosystem": "Linux"
          },
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-40314.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:51.366392855Z",
      "provider": "osv",
      "references": [
        "https://git.kernel.org/stable/c/0cf9a50af91fbdac3849f8d950e883a3eaa3ecea",
        "https://git.kernel.org/stable/c/37158ce6ba964b62d1e3eebd11f03c6900a52dd1",
        "https://git.kernel.org/stable/c/87c5ff5615dc0a37167e8faf3adeeddc6f1344a3",
        "https://git.kernel.org/stable/c/9c52f01429c377a2d32cafc977465f37b5384f77",
        "https://git.kernel.org/stable/c/ea37884097a0931abb8e11e40eacfb25e9fdb5e9",
        "https://git.kernel.org/stable/c/fdf573c517627a96f5040f988e9b21267806be5c",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/40xxx/CVE-2025-40314.json",
        "https://nvd.nist.gov/vuln/detail/CVE-2025-40314",
        "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
      ],
      "provider_metadata": {
        "cna_assigner": "Linux",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/40xxx/CVE-2025-40314.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2025-40314",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": null
  },
  "source_id": "core-osv",
  "document_id": 519590,
  "published_at": "2025-12-08T00:46:40.576+00:00"
}