From: Alexander Kappner Date: Wed, 28 Mar 2018 22:18:31 +0000 (-0700) Subject: mmc: core: Prevent bus reference leak in mmc_blk_init() X-Git-Tag: v5.15~8979^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0a0852b9f81cf5f793bf2eae7336ed40a1a1815;p=platform%2Fkernel%2Flinux-starfive.git mmc: core: Prevent bus reference leak in mmc_blk_init() Upon module load, mmc_block allocates a bus with bus_registeri() in mmc_blk_init(). This reference never gets freed during module unload, which leads to subsequent re-insertions of the module fails and a WARN() splat is triggered. Fix the bug by dropping the reference for the bus in mmc_blk_exit(). Signed-off-by: Alexander Kappner Fixes: 97548575bef3 ("mmc: block: Convert RPMB to a character device") Cc: Reviewed-by: Shawn Lin Signed-off-by: Ulf Hansson --- diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index a2b9c25..758657e 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -3080,6 +3080,7 @@ static void __exit mmc_blk_exit(void) mmc_unregister_driver(&mmc_driver); unregister_blkdev(MMC_BLOCK_MAJOR, "mmc"); unregister_chrdev_region(mmc_rpmb_devt, MAX_DEVICES); + bus_unregister(&mmc_rpmb_bus_type); } module_init(mmc_blk_init);