[PATCH] mtd: retain the partition node reference across device registration
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Sun Nov 8 13:17:29 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mtd: incorrect Fixes trailer commit in mtd_find_of_node() change
--
commit 43323e99a46a84cff0195c53099ca6a7a7215432
Author: James Hilliard <james.hilliard1 at gmail.com>
> mtd: retain the partition node reference across device registration
>
> mtd_check_of_node() obtains a child node reference while looking up a
> partition, stores the node in the MTD device, and drops the reference.
> add_mtd_device() only takes its own reference after the helper returns.
> A concurrent dynamic DT removal can release the node in that gap.
>
> Return a referenced node from the lookup helper and transfer that reference
> to the MTD device. For an already supplied node, acquire the reference in
> the same helper. The existing registration unwind and device release paths
> remain responsible for putting it.
>
> Fixes: ad9b10d1eaad ("mtd: core: introduce of support for dynamic partitions")
> Cc: stable at vger.kernel.org
> Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>
[Severity: Low]
Should the Fixes: tag point to 5ab9bbf6c678 ("mtd: Fix possible refcounting
issue when going through partition nodes") instead?
Commit ad9b10d1eaad ("mtd: core: introduce of support for dynamic
partitions") broke out of for_each_child_of_node() without calling
of_node_put(mtd_dn), keeping the reference held across the return to
add_mtd_device(). Commit 5ab9bbf6c678 ("mtd: Fix possible refcounting issue
when going through partition nodes") added the of_node_put(mtd_dn) call in
mtd_check_of_node(), creating the window where the reference is dropped
before add_mtd_device() calls of_node_get().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261108-submit-mtd-partition-node-reference-v1-v1-1-ad30359569d4@gmail.com?part=1
More information about the linux-mtd
mailing list