xen/sched_rc: Fix memory leak in rt_init()
PATCH 1/1 xen/sched_rc: Fix memory leak in rt_init()
Introduced by c/s 376bbba "sched_rt: print useful affinity info when dumping". If the allocation of cpumask failed, prv was leaked.
Coverity-ID: 1304398
CC: Keir Fraser <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Dario Faggioli <[email protected]>
CC: George Dunlap <[email protected]>
CC: Meng Xu <[email protected]>
--- xen/common/sched_rt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
xen/common/sched_rt.c +5 -1
@@ -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
Signature · 1 line
1.7.10.4
Quoted 3 lines · Andrew Cooper
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? :-//
Quoted 8 lines
Signed-off-by Andrew Cooper <[email protected]>Coverity-ID: 1304398
CC: Keir Fraser <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Dario Faggioli <[email protected]>
CC: George Dunlap <[email protected]>
CC: Meng Xu <[email protected]>
Although, I'd rather...
xen/common/sched_rt.c static inline struct list_head *rt_depletedq(const struct scheduler *ops) · line 445
Quoted 11 lines
xen/common/sched_rt.c +1
-1@@ -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
Signature · 4 lines
<<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)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 05.06.15 at 11:49, <[email protected]> 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 <[email protected]>Coverity-ID: 1304398
I took the liberty to commit this without your ack, as being an obvious fix.
Jan