From: Andrew Cooper Subject: [PATCH] xen/sched_rc: Fix memory leak in rt_init() Date: Fri, 5 Jun 2015 10:49:36 +0100 Message-ID: <1433497776-8385-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Keir Fraser , George Dunlap , Andrew Cooper , Dario Faggioli , Meng Xu , Jan Beulich List-Id: xen-devel@lists.xenproject.org Introduced by c/s 376bbba "sched_rt: print useful affinity info when dumping". If the allocation of cpumask failed, prv was leaked. Signed-off-by: Andrew Cooper Coverity-ID: 1304398 CC: Keir Fraser CC: Jan Beulich CC: Dario Faggioli CC: George Dunlap CC: Meng Xu --- xen/common/sched_rt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 5836d27..4372486 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -441,7 +441,7 @@ static inline struct list_head *rt_depletedq(const struct scheduler *ops) { _cpumask_scratch = xmalloc_array(cpumask_var_t, nr_cpu_ids); if ( !_cpumask_scratch ) - return -ENOMEM; + goto no_mem; } nr_rt_ops++; @@ -455,6 +455,10 @@ static inline struct list_head *rt_depletedq(const struct scheduler *ops) ops->sched_data = prv; return 0; + + no_mem: + xfree(prv); + return -ENOMEM; } static void -- 1.7.10.4