summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2019-02-18 16:12:44 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2019-02-20 21:17:16 +0000
commitffe245b40fe1731e6f0ea5c097a74eb78bc839e2 (patch)
tree93f32ea3a352e86510f900dd21c561269392075e
parentb9e319bfd413f32cc39ec7b8ccc527f35712da7f (diff)
downloadillumos-joyent-ffe245b40fe1731e6f0ea5c097a74eb78bc839e2.tar.gz
10415 Memory leak in ipadm_zone_get_network()
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Sebastian Wiedenroth <sebastian.wiedenroth@skylime.net> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--usr/src/lib/libipadm/common/ipadm_ngz.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr/src/lib/libipadm/common/ipadm_ngz.c b/usr/src/lib/libipadm/common/ipadm_ngz.c
index 899eb47ff0..9effd285d1 100644
--- a/usr/src/lib/libipadm/common/ipadm_ngz.c
+++ b/usr/src/lib/libipadm/common/ipadm_ngz.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
*/
#include <errno.h>
@@ -347,6 +348,7 @@ i_ipadm_zone_get_network(zoneid_t zoneid, datalink_id_t linkid, int type,
void *buf, size_t *bufsize)
{
zone_net_data_t *zndata;
+ ipadm_status_t ret = IPADM_SUCCESS;
zndata = calloc(1, sizeof (*zndata) + *bufsize);
if (zndata == NULL)
@@ -357,11 +359,14 @@ i_ipadm_zone_get_network(zoneid_t zoneid, datalink_id_t linkid, int type,
if (zone_getattr(zoneid, ZONE_ATTR_NETWORK, zndata,
sizeof (*zndata) + *bufsize) < 0) {
- return (ipadm_errno2status(errno));
+ ret = ipadm_errno2status(errno);
+ goto out;
}
*bufsize = zndata->zn_len;
bcopy(zndata->zn_val, buf, *bufsize);
- return (IPADM_SUCCESS);
+out:
+ free(zndata);
+ return (ret);
}
/*
@@ -447,7 +452,7 @@ fail:
*/
ipadm_status_t
ipadm_init_net_from_gz(ipadm_handle_t iph, char *ifname,
- void (*persist_if)(char *, boolean_t, boolean_t))
+ void (*persist_if)(char *, boolean_t, boolean_t))
{
ngz_walk_data_t nwd;
uint64_t flags;