aboutsummaryrefslogtreecommitdiff
path: root/hw/net
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2015-06-25 14:24:10 +0800
committerStefan Hajnoczi <stefanha@redhat.com>2015-07-07 13:10:26 +0100
commitec50dd4634ae06091e61f42b7ba975f9ed510ad0 (patch)
tree5905557d9573f72a414e7c5b2d7304d0b334a581 /hw/net
parentf6e3035f75e5c6a73485335765ae070304c7a110 (diff)
rocker: fix memory leak
Meanwhile, using g_new0 instead of g_malloc0, refer to commit 5839e53. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Message-id: 1435213450-6700-1-git-send-email-arei.gonglei@huawei.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'hw/net')
-rw-r--r--hw/net/rocker/rocker.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index 4d25842509..7e060153ab 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -96,7 +96,7 @@ World *rocker_get_world(Rocker *r, enum rocker_world_type type)
RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
{
- RockerSwitch *rocker = g_malloc0(sizeof(*rocker));
+ RockerSwitch *rocker;
Rocker *r;
r = rocker_find(name);
@@ -106,6 +106,7 @@ RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
return NULL;
}
+ rocker = g_new0(RockerSwitch, 1);
rocker->name = g_strdup(r->name);
rocker->id = r->switch_id;
rocker->ports = r->fp_ports;