The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/3380
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From ba7536c0707890d478406484ea5a2ac391d4df4b Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Wed, 15 Apr 2020 11:15:56 +0200 Subject: [PATCH 1/2] memory_utils: directly NULL ptr in free_disarm() This should keep coverity happy. Fixes: Coverity 1461757. Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- src/lxc/memory_utils.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lxc/memory_utils.h b/src/lxc/memory_utils.h index 29878fb67d..d3b68a1e90 100644 --- a/src/lxc/memory_utils.h +++ b/src/lxc/memory_utils.h @@ -41,10 +41,10 @@ define_cleanup_function(FILE *, fclose); define_cleanup_function(DIR *, closedir); #define __do_closedir call_cleaner(closedir) -#define free_disarm(ptr) \ - ({ \ - free(ptr); \ - move_ptr(ptr); \ +#define free_disarm(ptr) \ + ({ \ + free(ptr); \ + ptr = NULL; \ }) static inline void free_disarm_function(void *ptr) From a1f3b050fce63581fc413267a11e8320fea1c3a4 Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Wed, 15 Apr 2020 11:30:45 +0200 Subject: [PATCH 2/2] conf: fix tty cleanup Fixes: Coverity 1461755. Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- src/lxc/conf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 45acc71a91..45a7db1e9f 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -901,11 +901,13 @@ static int lxc_setup_ttys(struct lxc_conf *conf) return 0; } +define_cleanup_function(struct lxc_tty_info *, lxc_delete_tty); + int lxc_allocate_ttys(struct lxc_conf *conf) { - __do_free struct lxc_terminal_info *tty_new = NULL; + struct lxc_terminal_info *tty_new = NULL; int ret; - struct lxc_tty_info *ttys = &conf->ttys; + call_cleaner(lxc_delete_tty) struct lxc_tty_info *ttys = &conf->ttys; /* no tty in the configuration */ if (ttys->max == 0) @@ -924,14 +926,12 @@ int lxc_allocate_ttys(struct lxc_conf *conf) ret = openpty(&tty->master, &tty->slave, NULL, NULL, NULL); if (ret < 0) { ttys->max = i; - lxc_delete_tty(ttys); return log_error_errno(-ENOTTY, ENOTTY, "Failed to create tty %zu", i); } ret = ttyname_r(tty->slave, tty->name, sizeof(tty->name)); if (ret < 0) { ttys->max = i; - lxc_delete_tty(ttys); return log_error_errno(-ENOTTY, ENOTTY, "Failed to retrieve name of tty %zu slave", i); } @@ -954,6 +954,7 @@ int lxc_allocate_ttys(struct lxc_conf *conf) INFO("Finished creating %zu tty devices", ttys->max); ttys->tty = move_ptr(tty_new); + move_ptr(ttys); return 0; }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel