# CVE-2022-50304: mtd: core: fix possible resource leak in init\_mtd()

> 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.23% (percentile 8, 2026-11-26)
- **CWE:** CWE-401
- **Published:** 2025-09-15T14:45:59.614Z
- **Modified:** 2026-11-05T20:17:33.237Z

## Who should check

- Anyone running Linux \>= 445caaa20c4d6da74f426464f90513b81157ad77, \< 78816504100cbd8e6836df9f58cc4fbb8b262f1c; \>= 445caaa20c4d6da74f426464f90513b81157ad77, \< 26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4; \>= 445caaa20c4d6da74f426464f90513b81157ad77, \< 1aadf01e5076b9ab6bf294b9622335c651314895
- Anyone running Linux 4.10

## Description

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

mtd: core: fix possible resource leak in init\_mtd()

I got the error report while inject fault in init\_mtd():

sysfs: cannot create duplicate filename '/devices/virtual/bdi/mtd-0'
Call Trace:
 \<TASK\>
 dump\_stack\_lvl+0x67/0x83
 sysfs\_warn\_dup+0x60/0x70
 sysfs\_create\_dir\_ns+0x109/0x120
 kobject\_add\_internal+0xce/0x2f0
 kobject\_add+0x98/0x110
 device\_add+0x179/0xc00
 device\_create\_groups\_vargs+0xf4/0x100
 device\_create+0x7b/0xb0
 bdi\_register\_va.part.13+0x58/0x2d0
 bdi\_register+0x9b/0xb0
 init\_mtd+0x62/0x171 \[mtd\]
 do\_one\_initcall+0x6c/0x3c0
 do\_init\_module+0x58/0x222
 load\_module+0x268e/0x27d0
 \_\_do\_sys\_finit\_module+0xd5/0x140
 do\_syscall\_64+0x37/0x90
 entry\_SYSCALL\_64\_after\_hwframe+0x63/0xcd
 \</TASK\>
kobject\_add\_internal failed for mtd-0 with -EEXIST, don't try to register
	things with the same name in the same directory.
Error registering mtd class or bdi: -17

If init\_mtdchar() fails in init\_mtd(), mtd\_bdi will not be unregistered,
as a result, we can't load the mtd module again, to fix this by calling
bdi\_unregister(mtd\_bdi) after out\_procfs label.

## Affected and fixed versions

- Linux: \>= 445caaa20c4d6da74f426464f90513b81157ad77, \< 78816504100cbd8e6836df9f58cc4fbb8b262f1c; \>= 445caaa20c4d6da74f426464f90513b81157ad77, \< 26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4; \>= 445caaa20c4d6da74f426464f90513b81157ad77, \< 1aadf01e5076b9ab6bf294b9622335c651314895 (cvelist)
- Linux: 4.10 (cvelist)

## Mitigation

- Upgrade Linux to 1aadf01e5076b9ab6bf294b9622335c651314895 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-50304. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2022-50304.md
Affected: Linux >= 445caaa20c4d6da74f426464f90513b81157ad77, < 78816504100cbd8e6836df9f58cc4fbb8b262f1c; >= 445caaa20c4d6da74f426464f90513b81157ad77, < 26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4; >= 445caaa20c4d6da74f426464f90513b81157ad77, < 1aadf01e5076b9ab6bf294b9622335c651314895; Linux 4.10
Fixed in: Linux 78816504100cbd8e6836df9f58cc4fbb8b262f1c, Linux 26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4, Linux 1aadf01e5076b9ab6bf294b9622335c651314895

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-50304 being exploited?

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

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

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

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

Linux \>= 445caaa20c4d6da74f426464f90513b81157ad77, \< 78816504100cbd8e6836df9f58cc4fbb8b262f1c; \>= 445caaa20c4d6da74f426464f90513b81157ad77, \< 26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4; \>= 445caaa20c4d6da74f426464f90513b81157ad77, \< 1aadf01e5076b9ab6bf294b9622335c651314895; Linux 4.10.

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

Yes. Fixed in Linux 78816504100cbd8e6836df9f58cc4fbb8b262f1c, Linux 26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4, Linux 1aadf01e5076b9ab6bf294b9622335c651314895. Upgrade Linux to 1aadf01e5076b9ab6bf294b9622335c651314895 or later.

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

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/78816504100cbd8e6836df9f58cc4fbb8b262f1c>
- patch: <https://git.kernel.org/stable/c/26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4>
- patch: <https://git.kernel.org/stable/c/1aadf01e5076b9ab6bf294b9622335c651314895>

## 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-50304>

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