public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH block/for-linus] blkcg: fix gendisk reference leak in blkg_conf_prep()
@ 2015-07-22 22:05 Tejun Heo
  2015-07-22 22:07 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Tejun Heo @ 2015-07-22 22:05 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

When a blkcg configuration is targeted to a partition rather than a
whole device, blkg_conf_prep fails with -EINVAL; unfortunately, it
forgets to put the gendisk ref in that case.  Fix it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org
---
 block/blk-cgroup.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -791,8 +791,12 @@ int blkg_conf_prep(struct blkcg *blkcg,
 		return -EINVAL;
 
 	disk = get_gendisk(MKDEV(major, minor), &part);
-	if (!disk || part)
+	if (!disk)
 		return -EINVAL;
+	if (part) {
+		put_disk(disk);
+		return -EINVAL;
+	}
 
 	rcu_read_lock();
 	spin_lock_irq(disk->queue->queue_lock);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH block/for-linus] blkcg: fix gendisk reference leak in blkg_conf_prep()
  2015-07-22 22:05 [PATCH block/for-linus] blkcg: fix gendisk reference leak in blkg_conf_prep() Tejun Heo
@ 2015-07-22 22:07 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2015-07-22 22:07 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-kernel

On 07/22/2015 04:05 PM, Tejun Heo wrote:
> When a blkcg configuration is targeted to a partition rather than a
> whole device, blkg_conf_prep fails with -EINVAL; unfortunately, it
> forgets to put the gendisk ref in that case.  Fix it.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-22 22:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-22 22:05 [PATCH block/for-linus] blkcg: fix gendisk reference leak in blkg_conf_prep() Tejun Heo
2015-07-22 22:07 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox