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@citrix.com>
Reviewed-by: Meng Xu <mengxu@cis.upenn.edu>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Dario Faggioli <dario.faggioli@citrix.com>
static int
rt_init(struct scheduler *ops)
{
+ int rc = -ENOMEM;
struct rt_private *prv = xzalloc(struct rt_private);
printk("Initializing RTDS scheduler\n"
"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);
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