From: Christian Brauner Date: Wed, 3 Feb 2021 08:36:23 +0000 (+0100) Subject: tests: check for NULL in device_add_remove X-Git-Tag: lxc-5.0.0~303^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c981fcb784a8130570948bf8c78e69a1b1afdd4;p=thirdparty%2Flxc.git tests: check for NULL in device_add_remove Fixes: Coverity 1472768 Signed-off-by: Christian Brauner --- diff --git a/src/tests/device_add_remove.c b/src/tests/device_add_remove.c index 4cc400776..dd5c5d3ec 100644 --- a/src/tests/device_add_remove.c +++ b/src/tests/device_add_remove.c @@ -36,8 +36,8 @@ int main(int argc, char *argv[]) __do_close int fd_log = -EBADF; int ret = 1; struct lxc_log log = {}; + struct lxc_container *c = NULL; char template[sizeof(P_tmpdir"/attach_XXXXXX")]; - struct lxc_container *c; (void)strlcpy(template, P_tmpdir"/attach_XXXXXX", sizeof(template)); @@ -107,6 +107,7 @@ out: } (void)unlink(template); - lxc_container_put(c); + if (c) + lxc_container_put(c); return ret; }