Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memstick: mspro_block: Add error handling support for add_disk()

We never checked for errors on add_disk() as this function returned void.
Now that this is fixed, use the shiny new error handling.

Contrary to the typical removal which delays the put_disk() until later,
since we are failing on a probe we immediately put the disk on failure from
add_disk by using blk_cleanup_disk().

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20210902174105.2418771-4-mcgrof@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Luis Chamberlain and committed by
Ulf Hansson
b3f8eb6e 2304c55f

+5 -1
+5 -1
drivers/memstick/core/mspro_block.c
··· 1239 1239 set_capacity(msb->disk, capacity); 1240 1240 dev_dbg(&card->dev, "capacity set %ld\n", capacity); 1241 1241 1242 - device_add_disk(&card->dev, msb->disk, NULL); 1242 + rc = device_add_disk(&card->dev, msb->disk, NULL); 1243 + if (rc) 1244 + goto out_cleanup_disk; 1243 1245 msb->active = 1; 1244 1246 return 0; 1245 1247 1248 + out_cleanup_disk: 1249 + blk_cleanup_disk(msb->disk); 1246 1250 out_free_tag_set: 1247 1251 blk_mq_free_tag_set(&msb->tag_set); 1248 1252 out_release_id: