From: Miquel Raynal <miquel.raynal@bootlin.com>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] mtd: serialize dynamic partition registration with removal
Date: Fri, 20 Nov 2026 16:01:05 +0100 [thread overview]
Message-ID: <87h5hba6oe.fsf@bootlin.com> (raw)
In-Reply-To: <20261108-submit-mtd-partition-publication-v1-v1-1-cbff20b1351e@gmail.com> (James Hilliard's message of "Sun, 08 Nov 2026 14:13:59 -0700")
On 08/11/2026 at 14:13:59 -07, James Hilliard <james.hilliard1@gmail.com> wrote:
> mtd_add_partition() drops partitions_lock after linking the new child
> but before registering its MTD device and adding the partition sysfs
> attributes. Concurrent removal can unlink that child before it has been
> registered, or release it after registration but before the attributes
> are added. It can also finish deleting partitions before a new child
> is linked, leaving a partition published after master removal.
>
> Keep partitions_lock held across allocation, publication and attribute
> creation. Record that master unregistration has started under the same
> lock and reject new dynamic partitions from that point. Check before
> allocation, which can scan the parent's bad-block markers, so it cannot
> start hardware access after removal has passed this synchronization point.
>
> Initialize the state when registering the master, allowing drivers that
> reuse their MTD object to register it again.
>
> Fixes: 5daa7b21496a ("mtd: prepare partition add and del functions for ioctl requests")
> Cc: stable@vger.kernel.org
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
...
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -278,28 +278,34 @@ int mtd_add_partition(struct mtd_info *parent, const char *name,
> part.size = length;
> part.offset = offset;
Open question: would a guard(mutex) prevent most of the code churn
here?
Miquèl
prev parent reply other threads:[~2026-11-20 15:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 21:13 James Hilliard
2026-11-20 15:01 ` Miquel Raynal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h5hba6oe.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=james.hilliard1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®