Skip to content

Commit

Permalink
coverity: free 'result' in error case.
Browse files Browse the repository at this point in the history
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information
hallyn authored and stgraber committed Jul 1, 2015
1 parent 96c29b2 commit d6723be
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/lxc/conf.c
Expand Up @@ -4558,6 +4558,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
Expand All @@ -4582,6 +4593,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;
Expand All @@ -4599,4 +4611,4 @@ struct lxc_list *sort_cgroup_settings(struct lxc_list* cgroup_settings)
}

return result;
}
}

0 comments on commit d6723be

Please sign in to comment.