Re: [PATCH] blk-mq: only unregister sysfs when registration succeeded
From: Yu Kuai
Date: Sat Nov 12 2022 - 05:57:39 EST
在 2022/11/12 18:44, Yu Kuai 写道:
Hi,
在 2022/11/12 19:07, Liu Shixin 写道:
kobject_del() must not be called if kobject_add() has not been called.
Hence only unregister sysfs when registration succeeded.
From what I see, the blk_queue_registered() from caller
blk_unregister_queue() can already prevent that. QUEUE_FLAG_REGISTERED
will only be set if blk_register_queue() succeed.
I see that the return value of blk_mq_sysfs_register() is not checked
from blk_register_queue(), there will be memleak or uaf from error path.
Hence I think better thing to do is to handle the case that
blk_mq_sysfs_register() faild, and clean up if blk_mq_sysfs_register()
succeed while follow up procedures failed from blk_register_queue().