block: blkg_conf_finish fix module refcount
diff mbox

Message ID 1454641325-878-1-git-send-email-huaixin.chx@alibaba-inc.com
State New
Headers show

Commit Message

hansechang@gmail.com Feb. 5, 2016, 3:02 a.m. UTC
From: Chang Huaixin <huaixin.chx@alibaba-inc.com>

Blkg_conf_finish is used after blkg_conf_prep.

Blkg_conf_prep calls get_disk and increases module refcount. However,
blkg_conf_finish only calls put_disk which doesn't decrease module refcount.
So we call module_put here additionally to keep module refcount balanced.

Signed-off-by: Chang Huaixin <huaixin.chx@alibaba-inc.com>
---
 block/blk-cgroup.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Shaohua Li Feb. 9, 2016, 5:59 p.m. UTC | #1
On Fri, Feb 05, 2016 at 11:02:05AM +0800, hansechang@gmail.com wrote:
> From: Chang Huaixin <huaixin.chx@alibaba-inc.com>
> 
> Blkg_conf_finish is used after blkg_conf_prep.
> 
> Blkg_conf_prep calls get_disk and increases module refcount. However,
> blkg_conf_finish only calls put_disk which doesn't decrease module refcount.
> So we call module_put here additionally to keep module refcount balanced.

This is reported several times. Jens, could you pick up one?

http://marc.info/?l=linux-kernel&m=145255224414075&w=2
http://marc.info/?l=linux-kernel&m=145433834930392&w=2
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jens Axboe Feb. 9, 2016, 7:34 p.m. UTC | #2
On 02/09/2016 10:59 AM, Shaohua Li wrote:
> On Fri, Feb 05, 2016 at 11:02:05AM +0800, hansechang@gmail.com wrote:
>> From: Chang Huaixin <huaixin.chx@alibaba-inc.com>
>>
>> Blkg_conf_finish is used after blkg_conf_prep.
>>
>> Blkg_conf_prep calls get_disk and increases module refcount. However,
>> blkg_conf_finish only calls put_disk which doesn't decrease module refcount.
>> So we call module_put here additionally to keep module refcount balanced.
>
> This is reported several times. Jens, could you pick up one?
>
> http://marc.info/?l=linux-kernel&m=145255224414075&w=2
> http://marc.info/?l=linux-kernel&m=145433834930392&w=2

Done, queued up for 4.5-rc

Patch
diff mbox

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 5a37188..15cbf36 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -853,6 +853,7 @@  void blkg_conf_finish(struct blkg_conf_ctx *ctx)
 {
 	spin_unlock_irq(ctx->disk->queue->queue_lock);
 	rcu_read_unlock();
+	module_put(ctx->disk->fops->owner);
 	put_disk(ctx->disk);
 }
 EXPORT_SYMBOL_GPL(blkg_conf_finish);