CVE-2022-50457

Source
https://cve.org/CVERecord?id=CVE-2022-50457
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2022-50457.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2022-50457
Downstream
Published
2025-10-01T11:45:30.263Z
Modified
2026-03-12T03:26:32.466032Z
Summary
mtd: core: Fix refcount error in del_mtd_device()
Details

In the Linux kernel, the following vulnerability has been resolved:

mtd: core: Fix refcount error in delmtddevice()

delmtddevice() will call ofnodeput() to mtdgetofnode(mtd), which is mtd->dev.ofnode. However, memset(&mtd->dev, 0) is called before ofnodeput(). As the result, ofnodeput() won't do anything in delmtddevice(), and causes the refcount leak.

delmtddevice() memset(&mtd->dev, 0, sizeof(mtd->dev) # clear mtd->dev ofnodeput() mtdgetofnode(mtd) # mtd->dev is cleared, can't locate ofnode # ofnodeput(NULL) won't do anything

Fix the error by caching the pointer of the device_node.

OF: ERROR: memory leak, expected refcount 1 instead of 2, ofnodeget()/ofnodeput() unbalanced - destroy cset entry: attach overlay node /spi/spi-sram@0 CPU: 3 PID: 275 Comm: python3 Tainted: G N 6.1.0-rc3+ #54 0d8a1edddf51f172ff5226989a7565c6313b08e2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dumpstacklvl+0x67/0x83 kobjectget+0x155/0x160 ofnodeget+0x1f/0x30 offwnodeget+0x43/0x70 fwnodehandleget+0x54/0x80 fwnodegetnthparent+0xc9/0xe0 fwnodefullnamestring+0x3f/0xa0 devicenodestring+0x30f/0x750 pointer+0x598/0x7a0 vsnprintf+0x62d/0x9b0 ... cfsoverlayrelease+0x30/0x90 configitemrelease+0xbe/0x1a0 configitemput+0x5e/0x80 configfsrmdir+0x3bd/0x540 vfsrmdir+0x18c/0x320 dormdir+0x198/0x330 __x64sysrmdir+0x2c/0x40 dosyscall64+0x37/0x90 entrySYSCALL64afterhwframe+0x63/0xcd

[miquel.raynal@bootlin.com: Light reword of the commit log]

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/50xxx/CVE-2022-50457.json"
}
References

Affected packages

Git / 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
00596576a05145a1b5672897a82ef87af00becf4
Fixed
f6016557f1ef7735963bd8691592d2797bbf91d2
Fixed
616dc895d982026f41f500c88d1bfea004938cc8
Fixed
56570bdad5e31c5c538cd6efff5c4510256e1bb4

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2022-50457.json"