]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mmc: block: fix RPMB device unregister ordering
authorAo Sun <ao.sun@transsion.com>
Mon, 6 Jul 2026 11:43:00 +0000 (11:43 +0000)
committerUlf Hansson <ulfh@kernel.org>
Mon, 6 Jul 2026 15:25:03 +0000 (17:25 +0200)
Since commit 7852028a35f0 ("mmc: block: register RPMB partition with
the RPMB subsystem"), each mmc RPMB partition is represented by two
device objects:
 - the mmc-owned device (`rpmb->dev`, backing the legacy /dev/mmcblkXrpmb
   char device) and
 - the rpmb-core device (`rdev`, backing /dev/rpmbN).

The child RPMB device holds a reference to its parent, so the
parent's release callback cannot be invoked if the child device
is still registered.

Remove rpmb_dev_unregister() from the parent release handler and
unregister the child RPMB device in the remove path before tearing
down the parent device.

Also delete the extra blank line between mmc_blk_remove_rpmb_part()
and {.

Fixes: 7852028a35f0 ("mmc: block: register RPMB partition with the RPMB subsystem")
Cc: stable@vger.kernel.org
Signed-off-by: Jiazi Li <jiazi.li@transsion.com>
Signed-off-by: Ao Sun <ao.sun@transsion.com>
Reviewed-by: Avri Altman <avri.altman@sandisk.com>
Signed-off-by: Ulf Hansson <ulfh@kernel.org>
drivers/mmc/core/block.c

index 0274e8d07660dd0e3af237da6ba91480d2c0a9da..54a923ba4f1e7d3bf0f3e303801c1f5639350b8d 100644 (file)
@@ -2715,7 +2715,6 @@ static void mmc_blk_rpmb_device_release(struct device *dev)
 {
        struct mmc_rpmb_data *rpmb = dev_get_drvdata(dev);
 
-       rpmb_dev_unregister(rpmb->rdev);
        mmc_blk_put(rpmb->md);
        ida_free(&mmc_rpmb_ida, rpmb->id);
        kfree(rpmb);
@@ -2930,8 +2929,8 @@ out_put_device:
 }
 
 static void mmc_blk_remove_rpmb_part(struct mmc_rpmb_data *rpmb)
-
 {
+       rpmb_dev_unregister(rpmb->rdev);
        cdev_device_del(&rpmb->chrdev, &rpmb->dev);
        put_device(&rpmb->dev);
 }