mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-26 12:26:11 +00:00
memstick/ms_block: Add check for alloc_ordered_workqueue
[ Upstream commit4f431a047a
] 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:0ab30494bc
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
93fc05ec59
commit
50cf0c9547
1 changed files with 8 additions and 1 deletions
|
@ -2116,6 +2116,11 @@ static int msb_init_disk(struct memstick_dev *card)
|
||||||
dbg("Set total disk size to %lu sectors", capacity);
|
dbg("Set total disk size to %lu sectors", capacity);
|
||||||
|
|
||||||
msb->io_queue = alloc_ordered_workqueue("ms_block", WQ_MEM_RECLAIM);
|
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);
|
INIT_WORK(&msb->io_work, msb_io_work);
|
||||||
sg_init_table(msb->prealloc_sg, MS_BLOCK_MAX_SEGS+1);
|
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);
|
msb_start(card);
|
||||||
rc = device_add_disk(&card->dev, msb->disk, NULL);
|
rc = device_add_disk(&card->dev, msb->disk, NULL);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out_cleanup_disk;
|
goto out_destroy_workqueue;
|
||||||
dbg("Disk added");
|
dbg("Disk added");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_destroy_workqueue:
|
||||||
|
destroy_workqueue(msb->io_queue);
|
||||||
out_cleanup_disk:
|
out_cleanup_disk:
|
||||||
put_disk(msb->disk);
|
put_disk(msb->disk);
|
||||||
out_free_tag_set:
|
out_free_tag_set:
|
||||||
|
|
Loading…
Reference in a new issue