]> git.hungrycats.org Git - linux/commitdiff
mmc: core: Prevent bus reference leak in mmc_blk_init()
authorAlexander Kappner <agk@godking.net>
Wed, 28 Mar 2018 22:18:31 +0000 (15:18 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Apr 2018 07:43:03 +0000 (09:43 +0200)
commit d0a0852b9f81cf5f793bf2eae7336ed40a1a1815 upstream.

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 <agk@godking.net>
Fixes: 97548575bef3 ("mmc: block: Convert RPMB to a character device")
Cc: <stable@vger.kernel.org>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mmc/core/block.c

index 2cfb963d9f379ed5a29c6d357430f7dd3a1a4a79..9c6f639d8a57400f411bd7d95ba582bfd7a4480f 100644 (file)
@@ -3087,6 +3087,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);