]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
client: fix additional memory leaks detected by Coverity Scan fix/coverity-annotations
authorVincent Bernat <vincent@bernat.ch>
Sun, 21 Mar 2021 14:25:19 +0000 (15:25 +0100)
committerVincent Bernat <vincent@bernat.ch>
Sun, 21 Mar 2021 14:29:25 +0000 (15:29 +0100)
src/client/conf-system.c
src/compat/daemon.c
src/daemon/lldpd.c

index 0764ed8338b83329abffb2d6a4112f9fc5f01760..9524d0dba22c45bd12b5826d09a91fee860e99f6 100644 (file)
@@ -209,6 +209,7 @@ cmd_hostname(struct lldpctl_conn_t *conn, struct writer *w,
        if (value && strlen(value) == 1 && value[0] == '.') {
                if (uname(&un) < 0) {
                        log_warn("lldpctl", "cannot get node name");
+                       lldpctl_atom_dec_ref(config);
                        return 0;
                }
                value = un.nodename;
@@ -280,6 +281,7 @@ cmd_bondslave_srcmac_type(struct lldpctl_conn_t *conn, struct writer *w,
 
        if (value == -1) {
                log_warnx("lldpctl", "invalid value");
+               lldpctl_atom_dec_ref(config);
                return 0;
        }
 
index 79e0bb6fe4d93e9a7704566f5c7a2a8f343e4dd2..cf7f81d53f9aae4207f7424e1f5e9c3712b4b9ce 100644 (file)
@@ -55,6 +55,8 @@ daemon(int nochdir, int noclose)
        if (!nochdir)
                (void)chdir("/");
 
+       /* coverity[resource_leak]
+          fd may be leaked if < 2, it's expected */
        if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) {
                (void)dup2(fd, STDIN_FILENO);
                (void)dup2(fd, STDOUT_FILENO);
@@ -62,7 +64,5 @@ daemon(int nochdir, int noclose)
                if (fd > 2)
                        (void)close (fd);
        }
-       /* coverity[resource_leak]
-          fd may be leaked if < 2, it's expected */
        return (0);
 }
index efc06c80d56f5e87d9a9b2bc0db12f8c7948c277..a7b2647b499c5581ccdd8c21d03c9d9c46f25984 100644 (file)
@@ -1740,14 +1740,14 @@ lldpd_main(int argc, char *argv[], char *envp[])
                /* So, we use syslog and we daemonize (or we are started by
                 * systemd). No need to continue writing to stdout. */
                int fd;
+               /* coverity[resource_leak]
+                  fd may be leaked if < 2, it's expected */
                if ((fd = open("/dev/null", O_RDWR, 0)) != -1) {
                        dup2(fd, STDIN_FILENO);
                        dup2(fd, STDOUT_FILENO);
                        dup2(fd, STDERR_FILENO);
                        if (fd > 2) close(fd);
                }
-               /* coverity[resource_leak]
-                  fd may be leaked if < 2, it's expected */
        }
        log_debug("main", "lldpd " PACKAGE_VERSION " starting...");
        version_check();