# CVE-2022-50304: mtd: core: fix possible resource leak in init_mtd()

CVE-2022-50304 is fixed in linux on 1 platform, first by DEBIAN-CVE-2022-50304, released September 15, 2025. It is not reported as exploited. Patch Radar priority: Routine.

- Web page: https://patchblox.com/security/cve/CVE-2022-50304
- Priority: Routine
- CVSS: 5.5 (Moderate)
- EPSS: 0.0016
- CISA KEV: not listed
- Exploited (vendor report): no
- Publicly disclosed: no
- Published: Sep 15, 2025
- Weakness: Missing Release of Memory after Effective Lifetime
- Vendor advisory: https://msrc.microsoft.com/update-guide/vulnerability/CVE-2022-50304

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

## Where it's fixed

| Platform | Product | Fixed in | Fix | Released |
|---|---|---|---|---|
| Linux | linux Debian 12.15 (bookworm) | 6.1.4-1 | [DEBIAN-CVE-2022-50304](https://patchblox.com/security/data/fix/linux/debian-cve-2022-50304.md) | Sep 15, 2025 |
| Linux | linux Debian 13.5 (trixie) | 6.1.4-1 | [DEBIAN-CVE-2022-50304](https://patchblox.com/security/data/fix/linux/debian-cve-2022-50304.md) | Sep 15, 2025 |
| Linux | linux Debian 14 | 6.1.4-1 | [DEBIAN-CVE-2022-50304](https://patchblox.com/security/data/fix/linux/debian-cve-2022-50304.md) | Sep 15, 2025 |

---

Data as of 2026-11-08T13:06:02Z UTC. Source: Patchblox Patch Radar (https://patchblox.com/security/patch-radar). Patchblox finds out-of-date software on Windows, macOS and Linux and updates it through release rings: https://patchblox.com/demo

Free to use with attribution: show "Data: Patchblox Patch Radar" with a link to https://patchblox.com/security/patch-radar. Terms, including what needs a written agreement: https://patchblox.com/security/patch-radar/use-the-data

Product names, logos and trademarks shown on Patch Radar belong to their respective owners. They are used only to identify the software each security fix applies to and to help readers find their platform. Their use does not imply any affiliation with, or endorsement by, those owners, and Patchblox is not affiliated with any of them.
