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/pcifront.c | |
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/pcifront.c')
-rw-r--r-- | extras/mini-os/pcifront.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/extras/mini-os/pcifront.c b/extras/mini-os/pcifront.c index b9be949363..641eca4e9f 100644 --- a/extras/mini-os/pcifront.c +++ b/extras/mini-os/pcifront.c @@ -181,6 +181,7 @@ again: err = xenbus_transaction_start(&xbt); if (err) { printk("starting transaction\n"); + free(err); } err = xenbus_printf(xbt, nodename, "pci-op-ref","%u", @@ -210,6 +211,7 @@ again: } err = xenbus_transaction_end(xbt, 0, &retry); + if (err) free(err); if (retry) { goto again; printk("completing transaction\n"); @@ -218,7 +220,8 @@ again: goto done; abort_transaction: - xenbus_transaction_end(xbt, 1, &retry); + free(err); + err = xenbus_transaction_end(xbt, 1, &retry); goto error; done: @@ -268,6 +271,7 @@ done: return dev; error: + free(err); free_pcifront(dev); return NULL; } @@ -341,6 +345,7 @@ void shutdown_pcifront(struct pcifront_dev *dev) state = xenbus_read_integer(path); while (err == NULL && state < XenbusStateClosing) err = xenbus_wait_for_state_change(path, &state, &dev->events); + if (err) free(err); if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != NULL) { printk("shutdown_pcifront: error changing state to %d: %s\n", @@ -348,8 +353,10 @@ void shutdown_pcifront(struct pcifront_dev *dev) goto close_pcifront; } state = xenbus_read_integer(path); - if (state < XenbusStateClosed) - xenbus_wait_for_state_change(path, &state, &dev->events); + if (state < XenbusStateClosed) { + err = xenbus_wait_for_state_change(path, &state, &dev->events); + free(err); + } if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateInitialising)) != NULL) { printk("shutdown_pcifront: error changing state to %d: %s\n", @@ -362,6 +369,7 @@ void shutdown_pcifront(struct pcifront_dev *dev) err = xenbus_wait_for_state_change(path, &state, &dev->events); close_pcifront: + if (err) free(err); xenbus_unwatch_path_token(XBT_NIL, path, path); snprintf(path, sizeof(path), "%s/info-ref", nodename); |