Coverity fix for CID 1125625
authorRajesh Joseph <rjoseph@redhat.com>
Thu, 16 Apr 2015 06:55:28 +0000 (12:25 +0530)
committerMartin Schwenke <martin@meltin.net>
Wed, 24 Feb 2016 06:11:49 +0000 (17:11 +1100)
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>
(Imported from commit a689cd5d955214fe94f19af9d1b5aec6d44d568a)

tools/ctdb.c

index 7979657d60db376b116a8301f596a705ac4acf09..2b40f16b2284f94f54fda33d6d07ec4bf5b8a16c 100644 (file)
@@ -2468,6 +2468,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();
@@ -2478,7 +2479,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;
 }