]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: free 'result' in error case.
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Sun, 17 May 2015 12:30:57 +0000 (07:30 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 28 Aug 2015 22:02:16 +0000 (18:02 -0400)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.c

index b6e4e49be3be9e5e29f0d0dbd881b4b9f3c15e44..c69cd65c1be7a7ac92c3c290e37b2fb0b202ab1a 100644 (file)
@@ -4830,6 +4830,17 @@ void suggest_default_idmap(void)
        free(uname);
 }
 
+static void free_cgroup_settings(struct lxc_list *result)
+{
+       struct lxc_list *iterator, *next;
+
+       lxc_list_for_each_safe(iterator, result, next) {
+               lxc_list_del(iterator);
+               free(iterator);
+       }
+       free(result);
+}
+
 /*
  * Return the list of cgroup_settings sorted according to the following rules
  * 1. Put memory.limit_in_bytes before memory.memsw.limit_in_bytes
@@ -4854,6 +4865,7 @@ struct lxc_list *sort_cgroup_settings(struct lxc_list* cgroup_settings)
                item = malloc(sizeof(*item));
                if (!item) {
                        ERROR("failed to allocate memory to sort cgroup settings");
+                       free_cgroup_settings(result);
                        return NULL;
                }
                item->elem = it->elem;