Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754059AbbGATaL (ORCPT ); Wed, 1 Jul 2015 15:30:11 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:36544 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753297AbbGATaI (ORCPT ); Wed, 1 Jul 2015 15:30:08 -0400 From: Anshul Garg X-Google-Original-From: Anshul Garg To: linux-kernel@vger.kernel.org, mingo@redhat.com, peterz@infradead.org Cc: aksgarg1989@gmail.com Subject: [PATCH] Sched/rt:Fix memory leak in alloc_rt_sched_group Date: Wed, 1 Jul 2015 12:29:26 -0700 Message-Id: <1435778966-36415-1-git-send-email-aksgarg1989@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: X-Antivirus: avast! (VPS 150701-2, 07/01/2015), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1644 Lines: 56 From: Anshul Garg Added code to free allocated memory by function alloc_rt_sched_group in case kzalloc api fails. Signed-off-by: Anshul Garg --- 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 f4d4b07..47213e9 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -177,7 +177,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); @@ -186,7 +186,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)); @@ -202,6 +202,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; } -- 1.7.9.5 --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/