[PATCH openEuler-1.0-LTS] block: fix resource leak in blk_register_queue() error path

hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IBWSWQ -------------------------------- When registering a queue fails after __blk_mq_register_dev() is successful but the function later encounters an error, we need to clean up the resources. Add the missing blk_mq_unregister_dev() call in the error path to properly clean up these resources and prevent a memory leak. Fixes: 320ae51feed5 ("blk-mq: new multi-queue block IO queueing mechanism") Signed-off-by: Zheng Qixing <zhengqixing@huawei.com> --- block/blk-sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 05d8a5b236f5..f758d8bac54d 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -989,6 +989,8 @@ int blk_register_queue(struct gendisk *disk) ret = elv_register_queue(q, false); if (ret) { mutex_unlock(&q->sysfs_lock); + if (q->mq_ops) + blk_mq_unregister_dev(dev, q); mutex_unlock(&queue_to_wrapper(q)->sysfs_dir_lock); kobject_del(&q->kobj); blk_trace_remove_sysfs(dev); -- 2.39.2

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/15914 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/5LG... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/15914 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/5LG...
participants (2)
-
patchwork bot
-
Zheng Qixing