From: Eduardo Lima (Etrunko)<eblima(a)br.ibm.com>
As revealed by Coverity scan report
https://bugzilla.redhat.com/show_bug.cgi?id=728245#c8
https://bugzilla.redhat.com/attachment.cgi?id=530435
This is the same case that was fixed in commit 57765ed. The function
cleanup_filter() does not free the variable itself. In future uses, consider
using cleanup_filters() instead.
Signed-off-by: Eduardo Lima (Etrunko)<eblima(a)br.ibm.com>
---
libxkutil/acl_parsing.c | 5 ++++-
src/Virt_AppliedFilterList.c | 8 ++++----
src/Virt_EntriesInFilterList.c | 2 +-
src/Virt_FilterEntry.c | 2 +-
src/Virt_FilterList.c | 6 +++---
src/Virt_NestedFilterList.c | 17 +++++++----------
6 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c
index 7cde1f0..5b6d7bb 100644
--- a/libxkutil/acl_parsing.c
+++ b/libxkutil/acl_parsing.c
@@ -357,8 +357,10 @@ static int parse_acl_filter(xmlNode *fnode, struct acl_filter
*filter)
if (parse_acl_rule(child, rule) == 0)
goto err;
- if (append_filter_rule(filter, rule) == 0)
+ if (append_filter_rule(filter, rule) == 0) {
+ cleanup_rule(rule);
goto err;
+ }
}
else if (XSTREQ(child->name, "filterref")) {
filter_ref = get_attr_value(child, "filter");
@@ -504,6 +506,7 @@ int get_filters(
break;
memcpy(&filters[i], filter, sizeof(*filter));
+ free(filter);
}
*list = filters;
diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c
index 6dad3cb..6567118 100644
--- a/src/Virt_AppliedFilterList.c
+++ b/src/Virt_AppliedFilterList.c
@@ -193,7 +193,7 @@ static CMPIStatus list_to_net(
if (filter == NULL)
goto out;
- cleanup_filter(filter);
+ cleanup_filters(&filter, 1);
/* get domains */
dcount = get_domain_list(conn,&doms);
@@ -331,7 +331,7 @@ static CMPIStatus net_to_list(
filter,
&instance);
- cleanup_filter(filter);
+ cleanup_filters(&filter, 1);
if (instance != NULL)
inst_list_add(list, instance);
@@ -515,7 +515,7 @@ static CMPIStatus CreateInstance(
free(domain_name);
free(net_name);
- cleanup_filter(filter);
+ cleanup_filters(&filter, 1);
cleanup_virt_devices(&device, 1);
virDomainFree(dom);
@@ -625,7 +625,7 @@ static CMPIStatus DeleteInstance(
free(domain_name);
free(net_name);
- cleanup_filter(filter);
+ cleanup_filters(&filter, 1);
cleanup_virt_devices(&device, 1);
virDomainFree(dom);
diff --git a/src/Virt_EntriesInFilterList.c b/src/Virt_EntriesInFilterList.c
index 5b95dd3..2c8ac47 100644
--- a/src/Virt_EntriesInFilterList.c
+++ b/src/Virt_EntriesInFilterList.c
@@ -83,7 +83,7 @@ static CMPIStatus list_to_rule(
}
}
- cleanup_filter(filter);
+ cleanup_filters(&filter, 1);
out:
virConnectClose(conn);
diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c
index ad87689..acc3d61 100644
--- a/src/Virt_FilterEntry.c
+++ b/src/Virt_FilterEntry.c
@@ -687,7 +687,7 @@ CMPIStatus get_rule_by_ref(
&s);
out:
free(filter_name);
- cleanup_filter(filter);
+ cleanup_filters(&filter, 1);
virConnectClose(conn);
return s;
diff --git a/src/Virt_FilterList.c b/src/Virt_FilterList.c
index 5df2a92..35d18a9 100644
--- a/src/Virt_FilterList.c
+++ b/src/Virt_FilterList.c
@@ -177,7 +177,7 @@ CMPIStatus get_filter_by_ref(const CMPIBroker *broker,
s = instance_from_filter(broker, context, reference, filter, instance);
out:
- cleanup_filter(filter);
+ cleanup_filters(&filter, 1);
virConnectClose(conn);
return s;
@@ -320,7 +320,7 @@ static CMPIStatus CreateInstance(
CU_DEBUG("CreateInstance complete");
out:
- cleanup_filter(filter);
+ cleanup_filters(&filter, 1);
virConnectClose(conn);
return s;
@@ -361,7 +361,7 @@ static CMPIStatus DeleteInstance(
delete_filter(conn, filter);
out:
- cleanup_filter(filter);
+ cleanup_filters(&filter, 1);
virConnectClose(conn);
return s;
diff --git a/src/Virt_NestedFilterList.c b/src/Virt_NestedFilterList.c
index a129f01..894cd7c 100644
--- a/src/Virt_NestedFilterList.c
+++ b/src/Virt_NestedFilterList.c
@@ -155,13 +155,11 @@ static CMPIStatus parent_to_child(
inst_list_add(list, instance);
}
- cleanup_filter(child_filter);
-
- child_filter = NULL;
+ cleanup_filters(&child_filter, 1);
instance = NULL;
}
- cleanup_filter(parent_filter);
+ cleanup_filters(&parent_filter, 1);
out:
virConnectClose(conn);
@@ -223,10 +221,9 @@ static CMPIStatus child_to_parent(
}
- cleanup_filter(&_list[i]);
}
- free(_list);
+ cleanup_filters(&_list, count);
out:
virConnectClose(conn);
@@ -390,8 +387,8 @@ static CMPIStatus CreateInstance(
CU_DEBUG("CreateInstance completed");
out:
- cleanup_filter(parent_filter);
- cleanup_filter(child_filter);
+ cleanup_filters(&parent_filter, 1);
+ cleanup_filters(&child_filter, 1);
virConnectClose(conn);
return s;
@@ -481,8 +478,8 @@ static CMPIStatus DeleteInstance(
CU_DEBUG("CreateInstance completed");
out:
- cleanup_filter(parent_filter);
- cleanup_filter(child_filter);
+ cleanup_filters(&parent_filter, 1);
+ cleanup_filters(&child_filter, 1);
virConnectClose(conn);
return s;
--
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent(a)linux.vnet.ibm.com