{"id":"CVE-2026-139460","aliases":["CVE-2026-139460"],"related":[],"kind":"vulnerability","state":"published","title":"PCI/P2PDMA: Do not tear down the allocate attribute on registration failure","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nPCI/P2PDMA: Do not tear down the allocate attribute on registration failure\n\npci_p2pdma_add_resource() installs pci_p2pdma_unmap_mappings() as a devres\naction with the devres allocated p2p_pgmap as its data, and only then adds\nthe range to the pool:\n\n  error = devm_add_action_or_reset(&pdev->dev, pci_p2pdma_unmap_mappings,\n                                   p2p_pgmap);\n  if (error)\n          goto pages_free;\n\n  p2pdma = rcu_dereference_protected(pdev->p2pdma, 1);\n  error = gen_pool_add_owner(p2pdma->pool, ...);\n  if (error)\n          goto pages_free;\n\nThe action removes the allocate attribute for the whole device, which tears\ndown existing userspace mappings of every BAR already registered on it.\nBoth failures here get that wrong, in opposite ways.\n\ndevm_add_action_or_reset() runs the action when it cannot allocate its\ndevres node, so an -ENOMEM while registering a second BAR unmaps the first\none. Use devm_add_action() and let the error path unwind only what this\ncall created.\n\ngen_pool_add_owner() allocates a chunk and can also fail with -ENOMEM.\nThere the action is registered, and the error path frees p2p_pgmap with\ndevm_kfree() while leaving the action pointing at it. On unbind devres\nruns the action and pci_p2pdma_unmap_mappings() dereferences\np2p_pgmap->mem->owner->kobj, which is freed memory. Give that failure its\nown label and drop the action with devm_remove_action(), which removes it\nwithout running it.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nPCI/P2PDMA: Do not tear down the allocate attribute on registration failure\n\npci_p2pdma_add_resource() installs pci_p2pdma_unmap_mappings() as a devres\naction with the devres allocated p2p_pgmap as its data, and only then adds\nthe range to the pool:\n\n  error = devm_add_action_or_reset(&pdev->dev, pci_p2pdma_unmap_mappings,\n                                   p2p_pgmap);\n  if (error)\n          goto pages_free;\n\n  p2pdma = rcu_dereference_protected(pdev->p2pdma, 1);\n  error = gen_pool_add_owner(p2pdma->pool, ...);\n  if (error)\n          goto pages_free;\n\nThe action removes the allocate attribute for the whole device, which tears\ndown existing userspace mappings of every BAR already registered on it.\nBoth failures here get that wrong, in opposite ways.\n\ndevm_add_action_or_reset() runs the action when it cannot allocate its\ndevres node, so an -ENOMEM while registering a second BAR unmaps the first\none. Use devm_add_action() and let the error path unwind only what this\ncall created.\n\ngen_pool_add_owner() allocates a chunk and can also fail with -ENOMEM.\nThere the action is registered, and the error path frees p2p_pgmap with\ndevm_kfree() while leaving the action pointing at it. On unbind devres\nruns the action and pci_p2pdma_unmap_mappings() dereferences\np2p_pgmap->mem->owner->kobj, which is freed memory. Give that failure its\nown label and drop the action with devm_remove_action(), which removes it\nwithout running it.","source":"cvelist"}],"published":"2026-11-30T13:34:57.583Z","modified":"2026-11-30T14:19:17.263Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"7e9c7ef83d785236f5a8c3761dd053fae9b92fb8","fixed":"ea24957f8be21b0724fcb968b73860257b718b63","status":"affected"},{"type":"git","introduced":"7e9c7ef83d785236f5a8c3761dd053fae9b92fb8","fixed":"4fea96c997265874cfa1788494f9ce2d413b6d92","status":"affected"},{"type":"git","introduced":"7e9c7ef83d785236f5a8c3761dd053fae9b92fb8","fixed":"29a3a087228b372b9e7ebaf363550e4a1c95ba61","status":"affected"},{"type":"git","introduced":"7e9c7ef83d785236f5a8c3761dd053fae9b92fb8","fixed":"7c4d6505a1f8a1ebe8019b7f988ed494b696653b","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"6.2","status":"affected"},{"type":"semver","introduced":"0","fixed":"6.2","status":"unaffected"},{"type":"semver","introduced":"6.12.120","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.18.65","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"7.3.6","lastAffected":"7.3.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.4-rc1","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"}],"references":[{"url":"https://git.kernel.org/stable/c/ea24957f8be21b0724fcb968b73860257b718b63","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/4fea96c997265874cfa1788494f9ce2d413b6d92","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/29a3a087228b372b9e7ebaf363550e4a1c95ba61","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/7c4d6505a1f8a1ebe8019b7f988ed494b696653b","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-139460","url":"https://www.cve.org/CVERecord?id=CVE-2026-139460","licence":"CVE Terms of Use","modified":"2026-11-30T13:34:57.583Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-139460","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-139460","licence":"Public domain","modified":"2026-11-30T14:19:17.263Z"}],"updatedAt":"2026-11-30T14:33:03.613Z","epss":{"score":0.00209,"percentile":0.11664,"date":"2026-12-01T12:00:22.000Z"}}