summaryrefslogtreecommitdiff
path: root/drivers/memstick/core
diff options
context:
space:
mode:
authorJiasheng Jiang <jiasheng@iscas.ac.cn>2022-11-26 09:25:58 +0800
committerUlf Hansson <ulf.hansson@linaro.org>2022-12-07 13:29:14 +0100
commit4f431a047a5c8698ed4b67e2760cfbeb5fffb69d (patch)
tree95dbca1405a350eb7e95aaecb59628da9cc30c74 /drivers/memstick/core
parent5c5301a147df77eb4479be9af74f65a334206602 (diff)
memstick/ms_block: Add check for alloc_ordered_workqueue
As the alloc_ordered_workqueue may return NULL pointer, it should be better to add check for the return value. Moreover, the msb->io_queue should be freed if error occurs later. Fixes: 0ab30494bc4f ("memstick: add support for legacy memorysticks") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Link: https://lore.kernel.org/r/20221126012558.34374-1-jiasheng@iscas.ac.cn Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/memstick/core')
-rw-r--r--drivers/memstick/core/ms_block.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
index ba8414519515..04115cd92433 100644
--- a/drivers/memstick/core/ms_block.c
+++ b/drivers/memstick/core/ms_block.c
@@ -2116,6 +2116,11 @@ static int msb_init_disk(struct memstick_dev *card)
dbg("Set total disk size to %lu sectors", capacity);
msb->io_queue = alloc_ordered_workqueue("ms_block", WQ_MEM_RECLAIM);
+ if (!msb->io_queue) {
+ rc = -ENOMEM;
+ goto out_cleanup_disk;
+ }
+
INIT_WORK(&msb->io_work, msb_io_work);
sg_init_table(msb->prealloc_sg, MS_BLOCK_MAX_SEGS+1);
@@ -2125,10 +2130,12 @@ static int msb_init_disk(struct memstick_dev *card)
msb_start(card);
rc = device_add_disk(&card->dev, msb->disk, NULL);
if (rc)
- goto out_cleanup_disk;
+ goto out_destroy_workqueue;
dbg("Disk added");
return 0;
+out_destroy_workqueue:
+ destroy_workqueue(msb->io_queue);
out_cleanup_disk:
put_disk(msb->disk);
out_free_tag_set: