diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-12-14 09:51:07 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-12-14 09:51:07 +0000 |
commit | 453414b284599a93944cc893b11f85028c1d7f76 (patch) | |
tree | 7c104656495f75b805518c7e0fbac4aabfa9c57f /extras/mini-os/console | |
parent | 82b68fcd0ab980313dc739d2974d2194f83f07f1 (diff) | |
download | xen-453414b284599a93944cc893b11f85028c1d7f76.tar.gz xen-453414b284599a93944cc893b11f85028c1d7f76.tar.bz2 xen-453414b284599a93944cc893b11f85028c1d7f76.zip |
mini-os: Fix memory leaks in blkfront, netfront, pcifront, etc.
The return value of Xenbus routines xenbus_transaction_start(),
xenbus_printf(), xenbus_transaction_end(), etc. is a pointer of error
message. This pointer should be passed to free() to release the
allocated memory when it is no longer needed.
Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
Diffstat (limited to 'extras/mini-os/console')
-rw-r--r-- | extras/mini-os/console/xencons_ring.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/extras/mini-os/console/xencons_ring.c b/extras/mini-os/console/xencons_ring.c index ad385b43f4..6d2814e492 100644 --- a/extras/mini-os/console/xencons_ring.c +++ b/extras/mini-os/console/xencons_ring.c @@ -203,7 +203,7 @@ struct consfront_dev *init_consfront(char *_nodename) char* err; char* message=NULL; int retry=0; - char* msg; + char* msg = NULL; char nodename[256]; char path[256]; static int consfrontends = 1; @@ -242,6 +242,7 @@ again: err = xenbus_transaction_start(&xbt); if (err) { printk("starting transaction\n"); + free(err); } err = xenbus_printf(xbt, nodename, "ring-ref","%u", @@ -278,6 +279,7 @@ again: err = xenbus_transaction_end(xbt, 0, &retry); + if (err) free(err); if (retry) { goto again; printk("completing transaction\n"); @@ -286,7 +288,8 @@ again: goto done; abort_transaction: - xenbus_transaction_end(xbt, 1, &retry); + free(err); + err = xenbus_transaction_end(xbt, 1, &retry); goto error; done: @@ -323,6 +326,8 @@ done: return dev; error: + free(msg); + free(err); free_consfront(dev); return NULL; } |