In message: [PATCH linux-yocto v6.12] Revert "mtd_blkdevs: add mtd_table_mutex
lock back to blktrans_{open, release} to avoid race condition"
on 16/12/2025 Kevin Hao wrote:
> From: Liwei Song <[email protected]>
>
> This reverts commit e94b04fcb7d227180b1e6a1bad4832ffedccb473.
>
> The issue that this patch is trying to resolve has been fixed by
> upstream commit 19bfa9ebebb5 ("mtd: use refcount to prevent corruption")
> so this local patch can be reverted, if not, it will cause an unbalanced
> refcnt issue when open/close mtd device.
>
> Signed-off-by: Liwei Song <[email protected]>
> Signed-off-by: Bruce Ashfield <[email protected]>
> ---
> Hi Bruce,
>
> The patch has already been merged into the v6.12 standard/base branch,
> but it was inadvertently reverted during the merge of the v6.12.62 stable
> kernel into certain BSP branches. Please reapply this patch to the following
> BSP branches:
> v6.12/standard/nxp-sdk-6.12/nxp-soc
> v6.12/standard/preempt-rt/nxp-sdk-6.12/nxp-soc
> v6.12/standard/xlnx-soc
> v6.12/standard/preempt-rt/xlnx-soc
Fixed
There's no mystery about how this happened. I completely forgot
I had just merged that patch, so when I saw a delta in those branches,
I incorrectly assumed it was the one you were describing and that
git merge hand't picked up the conflict .. so I did a manual sync
to make sure the branches were the same.
Bruce
> ---
> drivers/mtd/mtd_blkdevs.c | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
> index
> bb953f93c2b86ce3abede6c6ac7dcd0a2d03b403..47ead84407cdcf8f91fda92b71d6ea2095a31a34
> 100644
> --- a/drivers/mtd/mtd_blkdevs.c
> +++ b/drivers/mtd/mtd_blkdevs.c
> @@ -189,8 +189,6 @@ static int blktrans_open(struct gendisk *disk, blk_mode_t
> mode)
>
> kref_get(&dev->ref);
>
> - if (!mutex_trylock(&mtd_table_mutex))
> - return ret;
> mutex_lock(&dev->lock);
>
> if (dev->open)
> @@ -215,7 +213,6 @@ static int blktrans_open(struct gendisk *disk, blk_mode_t
> mode)
> unlock:
> dev->open++;
> mutex_unlock(&dev->lock);
> - mutex_unlock(&mtd_table_mutex);
> return ret;
>
> error_release:
> @@ -224,7 +221,6 @@ static int blktrans_open(struct gendisk *disk, blk_mode_t
> mode)
> error_put:
> module_put(dev->tr->owner);
> mutex_unlock(&dev->lock);
> - mutex_unlock(&mtd_table_mutex);
> blktrans_dev_put(dev);
> return ret;
> }
> @@ -233,8 +229,6 @@ static void blktrans_release(struct gendisk *disk)
> {
> struct mtd_blktrans_dev *dev = disk->private_data;
>
> - if (!mutex_trylock(&mtd_table_mutex))
> - return;
> mutex_lock(&dev->lock);
>
> if (--dev->open)
> @@ -249,7 +243,6 @@ static void blktrans_release(struct gendisk *disk)
> }
> unlock:
> mutex_unlock(&dev->lock);
> - mutex_unlock(&mtd_table_mutex);
> blktrans_dev_put(dev);
> }
>
>
> ---
> base-commit: ece8928b78ad84eb550ac96090f055aaa7963a47
> change-id: 20251216-v6-12-mtd-dbf0eabc2f6b
>
> Best regards,
> --
> Kevin Hao <[email protected]>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#16057):
https://lists.yoctoproject.org/g/linux-yocto/message/16057
Mute This Topic: https://lists.yoctoproject.org/mt/116803830/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-