ctdb: Coverity fix for CID 1125625
authorRajesh Joseph <rjoseph@redhat.com>
Thu, 16 Apr 2015 06:55:28 +0000 (12:25 +0530)
committerGünther Deschner <gd@samba.org>
Fri, 17 Apr 2015 12:12:19 +0000 (14:12 +0200)
Memory allocated by ctdb_sys_find_ifname is not
freed by the caller.

Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
ctdb/tools/ctdb.c

index e7f166dbb454175511f1a7d7ef2f2c59bfd42b53..66d038365526a07307d5167f643065c5196c6e9c 100644 (file)
@@ -2418,6 +2418,7 @@ static int control_addip(struct ctdb_context *ctdb, int argc, const char **argv)
 static int control_ipiface(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        ctdb_sock_addr addr;
+       char *iface = NULL;
 
        if (argc != 1) {
                usage();
@@ -2428,7 +2429,15 @@ static int control_ipiface(struct ctdb_context *ctdb, int argc, const char **arg
                return -1;
        }
 
-       printf("IP on interface %s\n", ctdb_sys_find_ifname(&addr));
+       iface = ctdb_sys_find_ifname(&addr);
+       if (iface == NULL) {
+               printf("Failed to get interface name for ip: %s", argv[0]);
+               return -1;
+       }
+
+       printf("IP on interface %s\n", iface);
+
+       free(iface);
 
        return 0;
 }