Skip to content

Commit

Permalink
block: remove a superflous queue kobject reference
Browse files Browse the repository at this point in the history
kobject_add already adds a reference to the parent that is dropped
on deletion, so don't bother grabbing another one.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Jun 28, 2022
1 parent cc5c516 commit 060f131
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions block/blk-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,14 +812,13 @@ int blk_register_queue(struct gendisk *disk)

mutex_lock(&q->sysfs_dir_lock);

ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
ret = kobject_add(&q->kobj, &dev->kobj, "%s", "queue");
if (ret < 0)
goto unlock;

ret = sysfs_create_group(&q->kobj, &queue_attr_group);
if (ret) {
kobject_del(&q->kobj);
kobject_put(&dev->kobj);
goto unlock;
}

Expand Down Expand Up @@ -883,7 +882,6 @@ int blk_register_queue(struct gendisk *disk)
mutex_unlock(&q->sysfs_lock);
mutex_unlock(&q->sysfs_dir_lock);
kobject_del(&q->kobj);
kobject_put(&dev->kobj);

return ret;
}
Expand Down Expand Up @@ -941,6 +939,4 @@ void blk_unregister_queue(struct gendisk *disk)
q->sched_debugfs_dir = NULL;
q->rqos_debugfs_dir = NULL;
mutex_unlock(&q->debugfs_mutex);

kobject_put(&disk_to_dev(disk)->kobj);
}

0 comments on commit 060f131

Please sign in to comment.