mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Anshul Garg <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: torvalds@linux-foundation.org, mingo@kernel.org,
	aksgarg1989@gmail.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, hpa@zytor.com,
	peterz@infradead.org
Subject: [tip:sched/core] sched/rt: Fix memory leak in alloc_rt_sched_group()
Date: Mon, 6 Jul 2015 08:35:58 -0700	[thread overview]
Message-ID: <tip-ecdd6804b7c9e15fe8fc836ba0233d9912834e8b@git.kernel.org> (raw)
In-Reply-To: <1435778966-36415-1-git-send-email-aksgarg1989@gmail.com>

Commit-ID:  ecdd6804b7c9e15fe8fc836ba0233d9912834e8b
Gitweb:     http://git.kernel.org/tip/ecdd6804b7c9e15fe8fc836ba0233d9912834e8b
Author:     Anshul Garg <aksgarg1989@gmail.com>
AuthorDate: Wed, 1 Jul 2015 12:29:26 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 6 Jul 2015 14:17:14 +0200

sched/rt: Fix memory leak in alloc_rt_sched_group()

Added code to free allocated memory by function
alloc_rt_sched_group() in case the kzalloc() API fails.

Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1435778966-36415-1-git-send-email-aksgarg1989@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/rt.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 0d193a24..cfa907d 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -193,7 +193,7 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent)
 		goto err;
 	tg->rt_se = kzalloc(sizeof(rt_se) * nr_cpu_ids, GFP_KERNEL);
 	if (!tg->rt_se)
-		goto err;
+		goto err_free_rt_rq;
 
 	init_rt_bandwidth(&tg->rt_bandwidth,
 			ktime_to_ns(def_rt_bandwidth.rt_period), 0);
@@ -202,7 +202,7 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent)
 		rt_rq = kzalloc_node(sizeof(struct rt_rq),
 				     GFP_KERNEL, cpu_to_node(i));
 		if (!rt_rq)
-			goto err;
+			goto err_free_rt_se;
 
 		rt_se = kzalloc_node(sizeof(struct sched_rt_entity),
 				     GFP_KERNEL, cpu_to_node(i));
@@ -218,6 +218,10 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent)
 
 err_free_rq:
 	kfree(rt_rq);
+err_free_rt_se:
+	kfree(tg->rt_se);
+err_free_rt_rq:
+	kfree(tg->rt_rq);
 err:
 	return 0;
 }

  reply	other threads:[~2015-07-06 15:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01 19:29 [PATCH] Sched/rt:Fix memory leak in alloc_rt_sched_group Anshul Garg
2015-07-06 15:35 ` tip-bot for Anshul Garg [this message]
2015-07-06 19:43   ` [tip:sched/core] sched/rt: Fix memory leak in alloc_rt_sched_group() Anshul Garg
2015-07-07  6:45     ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-ecdd6804b7c9e15fe8fc836ba0233d9912834e8b@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=aksgarg1989@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome