]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mmc: block: Add error handling support for add_disk()
authorLuis Chamberlain <mcgrof@kernel.org>
Mon, 30 Aug 2021 21:25:34 +0000 (14:25 -0700)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 12 Oct 2021 08:21:16 +0000 (10:21 +0200)
We never checked for errors on add_disk() as this function returned void.
Now that this is fixed, use the shiny new error handling.

The caller only cleanups the disk if we pass on an allocated md but on
error we return return ERR_PTR(ret), and so we must do all the unwinding
ourselves.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20210830212538.148729-5-mcgrof@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/block.c

index 431af5e8be2f89300f3809d493f6953d13c39e11..61590cf7a7b1b749d8a3ed4e4c8c813bd7e45194 100644 (file)
@@ -2442,9 +2442,14 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
        /* used in ->open, must be set before add_disk: */
        if (area_type == MMC_BLK_DATA_AREA_MAIN)
                dev_set_drvdata(&card->dev, md);
-       device_add_disk(md->parent, md->disk, mmc_disk_attr_groups);
+       ret = device_add_disk(md->parent, md->disk, mmc_disk_attr_groups);
+       if (ret)
+               goto err_cleanup_queue;
        return md;
 
+ err_cleanup_queue:
+       blk_cleanup_queue(md->disk->queue);
+       blk_mq_free_tag_set(&md->queue.tag_set);
  err_kfree:
        kfree(md);
  out: