diff options
author | Shivaprasad G Bhat <sbhat@linux.ibm.com> | 2019-07-17 03:19:43 -0500 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2019-08-21 17:17:11 +1000 |
commit | d758880586323da46e3e737eaefb950a7279dfba (patch) | |
tree | 5510949e1ad0948722cedce68d3c1d0062c7e25c | |
parent | 1872588ede5770751ebc0e1df9909c8a785cb549 (diff) | |
download | qemu-d758880586323da46e3e737eaefb950a7279dfba.zip qemu-d758880586323da46e3e737eaefb950a7279dfba.tar.gz qemu-d758880586323da46e3e737eaefb950a7279dfba.tar.bz2 |
ppc: fix memory leak in spapr_caps_add_properties
Free the capability name string after setting
the capability.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Message-Id: <156335156198.82682.8756968724044750843.stgit@lep8c.aus.stglabs.ibm.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r-- | hw/ppc/spapr_caps.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index a61bf32..481dfd2 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -793,7 +793,7 @@ void spapr_caps_add_properties(SpaprMachineClass *smc, Error **errp) for (i = 0; i < ARRAY_SIZE(capability_table); i++) { SpaprCapabilityInfo *cap = &capability_table[i]; - const char *name = g_strdup_printf("cap-%s", cap->name); + char *name = g_strdup_printf("cap-%s", cap->name); char *desc; object_class_property_add(klass, name, cap->type, @@ -801,11 +801,13 @@ void spapr_caps_add_properties(SpaprMachineClass *smc, Error **errp) NULL, cap, &local_err); if (local_err) { error_propagate(errp, local_err); + g_free(name); return; } desc = g_strdup_printf("%s", cap->description); object_class_property_set_description(klass, name, desc, &local_err); + g_free(name); g_free(desc); if (local_err) { error_propagate(errp, local_err); |