* [PATCH] block :blk-sysfs: fix refcount imbalance on the error path
@ 2019-06-03 7:46 Lin Yi
2019-06-03 14:55 ` Bart Van Assche
0 siblings, 1 reply; 2+ messages in thread
From: Lin Yi @ 2019-06-03 7:46 UTC (permalink / raw)
To: axboe; +Cc: linux-block, liujian6, csong, zhiyunq, yiqiuping, teroincn
kobject_add takes a refcount to the object dev->kobj, but forget to
release it on the error path, lead to a memory leak.
Signed-off-by: Lin Yi <teroincn@163.com>
---
block/blk-sysfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 75b5281..539b7cb 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -971,6 +971,7 @@ int blk_register_queue(struct gendisk *disk)
ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
if (ret < 0) {
blk_trace_remove_sysfs(dev);
+ kobject_put(&dev->kobj);
goto unlock;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] block :blk-sysfs: fix refcount imbalance on the error path
2019-06-03 7:46 [PATCH] block :blk-sysfs: fix refcount imbalance on the error path Lin Yi
@ 2019-06-03 14:55 ` Bart Van Assche
0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2019-06-03 14:55 UTC (permalink / raw)
To: Lin Yi, axboe; +Cc: linux-block, liujian6, csong, zhiyunq, yiqiuping
On 6/3/19 12:46 AM, Lin Yi wrote:
> kobject_add takes a refcount to the object dev->kobj, but forget to
> release it on the error path, lead to a memory leak.
>
> Signed-off-by: Lin Yi <teroincn@163.com>
> ---
> block/blk-sysfs.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 75b5281..539b7cb 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -971,6 +971,7 @@ int blk_register_queue(struct gendisk *disk)
> ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
> if (ret < 0) {
> blk_trace_remove_sysfs(dev);
> + kobject_put(&dev->kobj);
> goto unlock;
> }
Have you reviewed the other kobject_add() calls in the block layer? Are
there more such calls that need to be fixed?
Additionally, please add "Fixes:" and "Cc: stable" tags.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-03 14:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-03 7:46 [PATCH] block :blk-sysfs: fix refcount imbalance on the error path Lin Yi
2019-06-03 14:55 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).