]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: cleanup set_config_apparmor_raw()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 8 Dec 2020 13:50:25 +0000 (14:50 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 8 Dec 2020 14:40:49 +0000 (15:40 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index 373d0d6f038d7b2a75e949b5a64a1a53c09ea636..89029c22ce3497d1d56ddba9a366fbeea1b62046 100644 (file)
@@ -1504,26 +1504,22 @@ static int set_config_apparmor_raw(const char *key,
                                   struct lxc_conf *lxc_conf,
                                   void *data)
 {
-       char *elem;
-       struct lxc_list *list;
+       __do_free char *elem = NULL;
+       __do_free struct lxc_list *list = NULL;
 
        if (lxc_config_value_empty(value))
                return lxc_clear_apparmor_raw(lxc_conf);
 
        list = malloc(sizeof(*list));
-       if (!list) {
-               errno = ENOMEM;
-               return -1;
-       }
+       if (!list)
+               return ret_errno(ENOMEM);
 
        elem = strdup(value);
-       if (!elem) {
-               free(list);
-               return -1;
-       }
-       list->elem = elem;
+       if (!elem)
+               return ret_errno(ENOMEM);
 
-       lxc_list_add_tail(&lxc_conf->lsm_aa_raw, list);
+       list->elem = move_ptr(elem);
+       lxc_list_add_tail(&lxc_conf->lsm_aa_raw, move_ptr(list));
 
        return 0;
 }