[PATCH] mtd: leave the device type unset when naming fails

sashiko-bot at kernel.org sashiko-bot at kernel.org
Sun Nov 8 13:30:14 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mtd: inaccurate Fixes tag in commit message for add_mtd_device()
--

commit e76bbebb3c54ac45bcccfcf9ff4a9021c3ac0eac
Author: James Hilliard <james.hilliard1 at gmail.com>

> mtd: leave the device type unset when naming fails
>
> add_mtd_device() uses dev.type to reject a second registration of the
> same MTD. It sets that field before dev_set_name(), but the failure path
> for the name allocation leaves it set even though no device was
> registered. Retrying registration then warns and fails with -EEXIST.
>
> Set the type only after naming succeeds. The later registration error
> paths already clear it before releasing the device.
>
> Fixes: fa06052d637b ("mtd: Convert to dynamically allocated bdi infrastructure")
> Cc: stable at vger.kernel.org
> Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>

[Severity: Low]
Should the Fixes tag reference 6697dae1e2da ("mtd: capture device name
setting failure when adding mtd") instead?

While fa06052d637b ("mtd: Convert to dynamically allocated bdi
infrastructure") changed the duplicate registration guard in
add_mtd_device() to check mtd->dev.type, dev_set_name() was not checked
for errors at that point.  The fail_devname error path that returns before
device_register() with mtd->dev.type still set was introduced in
6697dae1e2da ("mtd: capture device name setting failure when adding mtd"),
and clearing mtd->dev.type on the fail_added path was added in
9d4af746af8c ("mtd: fix double free and WARN_ON in add_mtd_device() error
paths").

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261108-submit-mtd-devname-retry-v1-v1-1-a67f332c54dd@gmail.com?part=1



More information about the linux-mtd mailing list