From: Matthew Daley Date: Wed, 18 Sep 2013 03:38:02 +0000 (+1200) Subject: mini-os: fix various memory leaks in consfront X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=20aa9dcbf2c94aed4087d9becc3e8b18123631a9;p=people%2Fliuw%2Flibxenctrl-split%2Fmini-os.git mini-os: fix various memory leaks in consfront Coverity-ID: 1055816 Coverity-ID: 1055817 Coverity-ID: 1055818 Signed-off-by: Matthew Daley Acked-by: Samuel Thibault --- diff --git a/console/xenbus.c b/console/xenbus.c index 4194982..b317114 100644 --- a/console/xenbus.c +++ b/console/xenbus.c @@ -42,7 +42,8 @@ void free_consfront(struct consfront_dev *dev) close: if (err) free(err); - xenbus_unwatch_path_token(XBT_NIL, path, path); + err = xenbus_unwatch_path_token(XBT_NIL, path, path); + if (err) free(err); mask_evtchn(dev->evtchn); unbind_evtchn(dev->evtchn); @@ -58,7 +59,7 @@ close: struct consfront_dev *init_consfront(char *_nodename) { xenbus_transaction_t xbt; - char* err; + char* err = NULL; char* message=NULL; int retry=0; char* msg = NULL; @@ -87,7 +88,7 @@ struct consfront_dev *init_consfront(char *_nodename) snprintf(path, sizeof(path), "%s/backend-id", nodename); if ((res = xenbus_read_integer(path)) < 0) - return NULL; + goto error; else dev->dom = res; evtchn_alloc_unbound(dev->dom, console_handle_input, dev, &dev->evtchn); @@ -170,7 +171,7 @@ done: msg = xenbus_wait_for_state_change(path, &state, &dev->events); if (msg != NULL || state != XenbusStateConnected) { printk("backend not available, state=%d\n", state); - xenbus_unwatch_path_token(XBT_NIL, path, path); + err = xenbus_unwatch_path_token(XBT_NIL, path, path); goto error; } }