# CVE-2022-50457: mtd: core: Fix refcount error in del\_mtd\_device()

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.22% (percentile 7, 2026-11-26)
- **Published:** 2025-10-01T11:45:30.263Z
- **Modified:** 2026-10-30T13:17:14.620Z

## Who should check

- Anyone running Linux \>= 63aff1411fc609d737830b79c6b06ce62348c582, \< 0de86087b20675c53fda2bc903dfc26a7ec99856; \>= 00596576a05145a1b5672897a82ef87af00becf4, \< f6016557f1ef7735963bd8691592d2797bbf91d2; \>= 00596576a05145a1b5672897a82ef87af00becf4, \< 616dc895d982026f41f500c88d1bfea004938cc8; \>= 00596576a05145a1b5672897a82ef87af00becf4, \< 56570bdad5e31c5c538cd6efff5c4510256e1bb4
- Anyone running Linux 5.17

## Description

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

mtd: core: Fix refcount error in del\_mtd\_device()

del\_mtd\_device() will call of\_node\_put() to mtd\_get\_of\_node(mtd), which
is mtd-\>dev.of\_node. However, memset(&mtd-\>dev, 0) is called before
of\_node\_put(). As the result, of\_node\_put() won't do anything in
del\_mtd\_device(), and causes the refcount leak.

del\_mtd\_device()
    memset(&mtd-\>dev, 0, sizeof(mtd-\>dev) \# clear mtd-\>dev
    of\_node\_put()
        mtd\_get\_of\_node(mtd) \# mtd-\>dev is cleared, can't locate of\_node
                             \# of\_node\_put(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,
of\_node\_get()/of\_node\_put() 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\>
    dump\_stack\_lvl+0x67/0x83
    kobject\_get+0x155/0x160
    of\_node\_get+0x1f/0x30
    of\_fwnode\_get+0x43/0x70
    fwnode\_handle\_get+0x54/0x80
    fwnode\_get\_nth\_parent+0xc9/0xe0
    fwnode\_full\_name\_string+0x3f/0xa0
    device\_node\_string+0x30f/0x750
    pointer+0x598/0x7a0
    vsnprintf+0x62d/0x9b0
    ...
    cfs\_overlay\_release+0x30/0x90
    config\_item\_release+0xbe/0x1a0
    config\_item\_put+0x5e/0x80
    configfs\_rmdir+0x3bd/0x540
    vfs\_rmdir+0x18c/0x320
    do\_rmdir+0x198/0x330
    \_\_x64\_sys\_rmdir+0x2c/0x40
    do\_syscall\_64+0x37/0x90
    entry\_SYSCALL\_64\_after\_hwframe+0x63/0xcd

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

## Affected and fixed versions

- Linux: \>= 63aff1411fc609d737830b79c6b06ce62348c582, \< 0de86087b20675c53fda2bc903dfc26a7ec99856; \>= 00596576a05145a1b5672897a82ef87af00becf4, \< f6016557f1ef7735963bd8691592d2797bbf91d2; \>= 00596576a05145a1b5672897a82ef87af00becf4, \< 616dc895d982026f41f500c88d1bfea004938cc8; \>= 00596576a05145a1b5672897a82ef87af00becf4, \< 56570bdad5e31c5c538cd6efff5c4510256e1bb4 (cvelist)
- Linux: 5.17 (cvelist)

## Mitigation

- Upgrade Linux to 56570bdad5e31c5c538cd6efff5c4510256e1bb4 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2022-50457. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2022-50457.md
Affected: Linux >= 63aff1411fc609d737830b79c6b06ce62348c582, < 0de86087b20675c53fda2bc903dfc26a7ec99856; >= 00596576a05145a1b5672897a82ef87af00becf4, < f6016557f1ef7735963bd8691592d2797bbf91d2; >= 00596576a05145a1b5672897a82ef87af00becf4, < 616dc895d982026f41f500c88d1bfea004938cc8; >= 00596576a05145a1b567289…
Fixed in: Linux 0de86087b20675c53fda2bc903dfc26a7ec99856, Linux 616dc895d982026f41f500c88d1bfea004938cc8, Linux 56570bdad5e31c5c538cd6efff5c4510256e1bb4

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2022-50457 being exploited?

There is no confirmed exploitation: CVE-2022-50457 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.22% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2022-50457?

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2022-50457?

Linux \>= 63aff1411fc609d737830b79c6b06ce62348c582, \< 0de86087b20675c53fda2bc903dfc26a7ec99856; \>= 00596576a05145a1b5672897a82ef87af00becf4, \< f6016557f1ef7735963bd8691592d2797bbf91d2; \>= 00596576a05145a1b5672897a82ef87af00becf4, \< 616dc895d982026f41f500c88d1bfea004938cc8; \>= 00596576a05145a1b5672897a82ef87af00becf4, \< 56570bdad5e31c5c538cd6efff5c4510256e1bb4; Linux 5.17.

### Is there a fix for CVE-2022-50457?

Yes. Fixed in Linux 0de86087b20675c53fda2bc903dfc26a7ec99856, Linux 616dc895d982026f41f500c88d1bfea004938cc8, Linux 56570bdad5e31c5c538cd6efff5c4510256e1bb4. Upgrade Linux to 56570bdad5e31c5c538cd6efff5c4510256e1bb4 or later.

### How do I check if I'm affected by CVE-2022-50457?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/f6016557f1ef7735963bd8691592d2797bbf91d2>
- patch: <https://git.kernel.org/stable/c/616dc895d982026f41f500c88d1bfea004938cc8>
- patch: <https://git.kernel.org/stable/c/56570bdad5e31c5c538cd6efff5c4510256e1bb4>
- other: <https://git.kernel.org/stable/c/0de86087b20675c53fda2bc903dfc26a7ec99856>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2022-50457>

HTML: <https://flawdb.com/CVE-2022-50457> · JSON: <https://flawdb.com/api/v1/entries/CVE-2022-50457>
