On Tue, Apr 02, 2019 at 11:11:08AM -0700, Bart Van Assche wrote: > On Tue, 2019-04-02 at 10:55 +0800, Ming Lei wrote: > > Also, isn't it the typical practice to release kobject related resources in > > its release handler? > > A typical approach is to call kobject_del() before starting to clean up a Yes. > resource and to defer the final kfree() call to the release handler. I think > that's how it works today in the block layer core. That is easy to see in the > blk_mq_hw_sysfs_release() implementation: > > static void blk_mq_hw_sysfs_release(struct kobject *kobj) > { > struct blk_mq_hw_ctx *hctx = container_of(kobj, struct blk_mq_hw_ctx, > kobj); > free_cpumask_var(hctx->cpumask); > kfree(hctx->ctxs); > kfree(hctx); > } Right, then we should free other hctx fields here too, it is safe and reliable. Thanks, Ming