[PATCH 5.4 083/142] mmc: block: Fix use-after-free issue for rpmb
From: Greg Kroah-Hartman
Date: Mon Jun 01 2020 - 14:09:20 EST
From: Peng Hao <richard.peng@xxxxxxxx>
[ Upstream commit 202500d21654874aa03243e91f96de153ec61860 ]
The data structure member ârpmb->mdâ was passed to a call of the function
âmmc_blk_putâ after a call of the function âput_deviceâ. Reorder these
function calls to keep the data accesses consistent.
Fixes: 1c87f7357849 ("mmc: block: Fix bug when removing RPMB chardev ")
Signed-off-by: Peng Hao <richard.peng@xxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
[Uffe: Fixed up mangled patch and updated commit message]
Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/mmc/core/block.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 9d01b5dca519..7f480c6b1981 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2475,8 +2475,8 @@ static int mmc_rpmb_chrdev_release(struct inode *inode, struct file *filp)
struct mmc_rpmb_data *rpmb = container_of(inode->i_cdev,
struct mmc_rpmb_data, chrdev);
- put_device(&rpmb->dev);
mmc_blk_put(rpmb->md);
+ put_device(&rpmb->dev);
return 0;
}
--
2.25.1