All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/sched_rc: Fix memory leak in rt_init()
@ 2015-06-05  9:49 Andrew Cooper
  2015-06-05 10:07 ` Dario Faggioli
  2015-06-08 12:19 ` Jan Beulich
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Cooper @ 2015-06-05  9:49 UTC (permalink / raw)
  To: Xen-devel
  Cc: Keir Fraser, George Dunlap, Andrew Cooper, Dario Faggioli,
	Meng Xu, Jan Beulich

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 <andrew.cooper3@citrix.com>
Coverity-ID: 1304398
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: Dario Faggioli <dario.faggioli@citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Meng Xu <mengxu@cis.upenn.edu>
---
 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

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

* Re: [PATCH] xen/sched_rc: Fix memory leak in rt_init()
  2015-06-05  9:49 [PATCH] xen/sched_rc: Fix memory leak in rt_init() Andrew Cooper
@ 2015-06-05 10:07 ` Dario Faggioli
  2015-06-08 12:19 ` Jan Beulich
  1 sibling, 0 replies; 3+ messages in thread
From: Dario Faggioli @ 2015-06-05 10:07 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: George Dunlap, Keir Fraser, Meng Xu, Jan Beulich, Xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1587 bytes --]

On Fri, 2015-06-05 at 10:49 +0100, Andrew Cooper wrote:
> Introduced by c/s 376bbba "sched_rt: print useful affinity info when dumping".
> If the allocation of cpumask failed, prv was leaked.
> 
Wow... I really did a _great_ job with that patch, didn't I? :-//

> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Coverity-ID: 1304398
> CC: Keir Fraser <keir@xen.org>
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Dario Faggioli <dario.faggioli@citrix.com>
> CC: George Dunlap <george.dunlap@eu.citrix.com>
> CC: Meng Xu <mengxu@cis.upenn.edu>
>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>

Although, I'd rather...

> 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;
>
free it right away here (just one added line), instead of "clobbering"
the tail of the function, since it's just this.

But, really, I'm ok with the fix as is. Thanks for taking the time of
sending the patch! :-)

Regards, Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH] xen/sched_rc: Fix memory leak in rt_init()
  2015-06-05  9:49 [PATCH] xen/sched_rc: Fix memory leak in rt_init() Andrew Cooper
  2015-06-05 10:07 ` Dario Faggioli
@ 2015-06-08 12:19 ` Jan Beulich
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2015-06-08 12:19 UTC (permalink / raw)
  To: George Dunlap
  Cc: Andrew Cooper, Dario Faggioli, Keir Fraser, Meng Xu, Xen-devel

>>> On 05.06.15 at 11:49, <andrew.cooper3@citrix.com> wrote:
> 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 <andrew.cooper3@citrix.com>
> Coverity-ID: 1304398

I took the liberty to commit this without your ack, as being an
obvious fix.

Jan

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

end of thread, other threads:[~2015-06-08 12:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-05  9:49 [PATCH] xen/sched_rc: Fix memory leak in rt_init() Andrew Cooper
2015-06-05 10:07 ` Dario Faggioli
2015-06-08 12:19 ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.