]> git.itanic.dy.fi Git - linux-stable/commitdiff
mmc: block: Fix use-after-free issue for rpmb
authorPeng Hao <richard.peng@oppo.com>
Fri, 22 May 2020 09:29:25 +0000 (09:29 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jun 2020 06:21:20 +0000 (08:21 +0200)
[ 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@oppo.com>
Cc: stable@vger.kernel.org
[Uffe: Fixed up mangled patch and updated commit message]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mmc/core/block.c

index 9d01b5dca5198fdeabd8806f28efd7195844820b..7f480c6b19810f9190c772cda2fb16b8e4cdebd5 100644 (file)
@@ -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;
 }