[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] sched/rt: Fix memory leak in rt_init()
commit fdb9a18698c9ab8e8e8e875f20184b4aa5d62825 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Tue May 10 14:37:00 2016 +0100 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Tue May 10 15:50:33 2016 +0100 sched/rt: Fix memory leak in rt_init() c/s 2656bc7b0 "xen: adopt .deinit_pdata and improve timer handling" introduced a error path into rt_init() which leaked prv if the allocation of prv->repl_timer failed. Introduce an error cleanup path. Spotted by Coverity. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Meng Xu <mengxu@xxxxxxxxxxxxx> Release-acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx> CC: Dario Faggioli <dario.faggioli@xxxxxxxxxx> --- xen/common/sched_rt.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 7f8f411..aa3ffd2 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -581,6 +581,7 @@ replq_reinsert(const struct scheduler *ops, struct rt_vcpu *svc) static int rt_init(struct scheduler *ops) { + int rc = -ENOMEM; struct rt_private *prv = xzalloc(struct rt_private); printk("Initializing RTDS scheduler\n" @@ -588,11 +589,11 @@ rt_init(struct scheduler *ops) "Use at your own risk.\n"); if ( prv == NULL ) - return -ENOMEM; + goto err; prv->repl_timer = xzalloc(struct timer); if ( prv->repl_timer == NULL ) - return -ENOMEM; + goto err; spin_lock_init(&prv->lock); INIT_LIST_HEAD(&prv->sdom); @@ -603,8 +604,16 @@ rt_init(struct scheduler *ops) cpumask_clear(&prv->tickled); ops->sched_data = prv; + rc = 0; - return 0; + err: + if ( rc && prv ) + { + xfree(prv->repl_timer); + xfree(prv); + } + + return rc; } static void -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |