]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: fix assorted issues detected by Coverity Scan
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 25 Aug 2017 00:43:29 +0000 (21:43 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 25 Aug 2017 00:49:39 +0000 (21:49 -0300)
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
22 files changed:
bgpd/bgp_evpn.c
bgpd/bgp_route.c
bgpd/bgp_routemap.c
bgpd/rfapi/bgp_rfapi_cfg.c
bgpd/rfapi/rfapi_import.c
lib/routemap.c
ospf6d/ospf6_zebra.c
ospfd/ospf_te.c
ripd/ripd.c
ripngd/ripngd.c
zebra/if_netlink.c
zebra/interface.c
zebra/ioctl.c
zebra/irdp_packet.c
zebra/rt_netlink.c
zebra/rtadv.c
zebra/zebra_mpls.c
zebra/zebra_mroute.c
zebra/zebra_pw.c
zebra/zebra_vrf.c
zebra/zebra_vty.c
zebra/zebra_vxlan.c

index 0560dc46f961db6864c77465abc979c815e462a6..75c1237bca1a7cc39c70c315217c168b15debfc6 100644 (file)
@@ -2042,7 +2042,7 @@ static void evpn_mpattr_encode_type5(struct stream *s, struct prefix *p,
        /* Prefix contains RD, ESI, EthTag, IP length, IP, GWIP and VNI */
        stream_putc(s, 8 + 10 + 4 + 1 + len + 3);
        stream_put(s, prd->val, 8);
-       if (attr && attr)
+       if (attr)
                stream_put(s, &(attr->evpn_overlay.eth_s_id), 10);
        else
                stream_put(s, &temp, 10);
@@ -2052,7 +2052,7 @@ static void evpn_mpattr_encode_type5(struct stream *s, struct prefix *p,
                stream_put_ipv4(s, p_evpn_p->ip.ipaddr_v4.s_addr);
        else
                stream_put(s, &p_evpn_p->ip.ipaddr_v6, 16);
-       if (attr && attr) {
+       if (attr) {
                if (IS_IPADDR_V4(&p_evpn_p->ip))
                        stream_put_ipv4(s,
                                        attr->evpn_overlay.gw_ip.ipv4.s_addr);
index beb1e2a2a0513eba4b45c944846861a49c9a20dd..768b2b8fb613e0e490b68d5047d2a1368a8c1700 100644 (file)
@@ -10298,10 +10298,6 @@ static int bgp_show_neighbor_route(struct vty *vty, struct peer *peer,
                return CMD_WARNING;
        }
 
-       /* labeled-unicast routes live in the unicast table */
-       if (safi == SAFI_LABELED_UNICAST)
-               safi = SAFI_UNICAST;
-
        return bgp_show(vty, peer->bgp, afi, safi, type, &peer->su, use_json);
 }
 
index 5a5d2a5d5d4f6fe88ec0522327f5a8ed40ed274a..307880f9d191a33954ad4a08849175d2ae5d7ba1 100644 (file)
@@ -658,8 +658,10 @@ static void *route_match_vni_compile(const char *arg)
                return NULL;
 
        *vni = strtoul(arg, &end, 10);
-       if (*end != '\0')
+       if (*end != '\0') {
+               XFREE(MTYPE_ROUTE_MAP_COMPILED, vni);
                return NULL;
+       }
 
        return vni;
 }
index c8e2dd95254eddd31f34070036d3c2544c421061..e3b446f76ad69b862f860529aaeaffcf39b972c2 100644 (file)
@@ -2977,11 +2977,6 @@ DEFUN_NOSH (vnc_vrf_policy,
        struct rfapi_nve_group_cfg *rfg;
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* Search for name */
        rfg = bgp_rfapi_cfg_match_byname(bgp, argv[1]->arg,
                                         RFAPI_GROUP_CFG_VRF);
@@ -3012,10 +3007,6 @@ DEFUN (vnc_no_vrf_policy,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
        return bgp_rfapi_delete_named_nve_group(vty, bgp, argv[2]->arg,
                                                RFAPI_GROUP_CFG_VRF);
 }
@@ -3031,11 +3022,6 @@ DEFUN (vnc_vrf_policy_label,
        uint32_t label;
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* make sure it's still in list */
        if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
                /* Not in list anymore */
@@ -3145,11 +3131,6 @@ DEFUN (vnc_vrf_policy_rt_import,
        int is_export_bgp = 0;
        int is_export_zebra = 0;
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* make sure it's still in list */
        if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
                /* Not in list anymore */
@@ -3213,11 +3194,6 @@ DEFUN (vnc_vrf_policy_rt_export,
        VTY_DECLVAR_CONTEXT(bgp, bgp);
        int rc;
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* make sure it's still in list */
        if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
                /* Not in list anymore */
@@ -3253,11 +3229,6 @@ DEFUN (vnc_vrf_policy_rt_both,
        struct listnode *node;
        struct rfapi_rfg_name *rfgn;
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* make sure it's still in list */
        if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
                /* Not in list anymore */
@@ -3333,11 +3304,6 @@ DEFUN (vnc_vrf_policy_rd,
        VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* make sure it's still in list */
        if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
                /* Not in list anymore */
@@ -3420,11 +3386,6 @@ DEFUN_NOSH (vnc_l2_group,
        struct rfapi_l2_group_cfg *rfg;
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* Search for name */
        rfg = rfapi_l2_group_lookup_byname(bgp, argv[1]->arg);
 
@@ -3505,10 +3466,6 @@ DEFUN (vnc_no_l2_group,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
        return bgp_rfapi_delete_named_l2_group(vty, bgp, argv[3]->arg);
 }
 
@@ -3522,11 +3479,6 @@ DEFUN (vnc_l2_group_lni,
        VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg, rfg);
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* make sure it's still in list */
        if (!listnode_lookup(bgp->rfapi_cfg->l2_groups, rfg)) {
                /* Not in list anymore */
@@ -3549,11 +3501,6 @@ DEFUN (vnc_l2_group_labels,
        VTY_DECLVAR_CONTEXT(bgp, bgp);
        struct list *ll;
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* make sure it's still in list */
        if (!listnode_lookup(bgp->rfapi_cfg->l2_groups, rfg)) {
                /* Not in list anymore */
@@ -3589,11 +3536,6 @@ DEFUN (vnc_l2_group_no_labels,
        VTY_DECLVAR_CONTEXT(bgp, bgp);
        struct list *ll;
 
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
        /* make sure it's still in list */
        if (!listnode_lookup(bgp->rfapi_cfg->l2_groups, rfg)) {
                /* Not in list anymore */
@@ -3646,10 +3588,6 @@ DEFUN (vnc_l2_group_rt,
                vty_out(vty, "Unknown option, %s\n", argv[1]->arg);
                return CMD_ERR_NO_MATCH;
        }
-       if (!bgp) {
-               vty_out(vty, "No BGP process is configured\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
 
        /* make sure it's still in list */
        if (!listnode_lookup(bgp->rfapi_cfg->l2_groups, rfg)) {
index d63975a22bff02105ede300fb0d467b0dbfd905f..3f427c39031ee336ec05c1b44fda998dadc3c392 100644 (file)
@@ -3875,10 +3875,9 @@ rfapiBgpInfoFilteredImportFunction(safi_t safi)
 
        default:
                /* not expected */
+               zlog_err("%s: bad safi %d", __func__, safi);
                return NULL;
        }
-       zlog_err("%s: bad safi %d", __func__, safi);
-       return NULL;
 }
 
 void rfapiProcessUpdate(struct peer *peer,
index a70248633c087d68a9fa232765b31ac3a5d2de7a..5f74189700611513fa6dcdc83961e6c5fe9305f6 100644 (file)
@@ -2201,7 +2201,7 @@ DEFUN (no_set_ip_nexthop,
        "Next hop address\n"
        "IP address of next hop\n")
 {
-       int idx;
+       int idx = 0;
        VTY_DECLVAR_CONTEXT(route_map_index, index);
        const char *arg = NULL;
 
index 3443bc47b616acd3900294bbc4c3e1b4daeb71e7..2d04790d235ae26992cdab51acd70686f5047b0b 100644 (file)
@@ -231,11 +231,7 @@ static int ospf6_zebra_read_route(int command, struct zclient *zclient,
                char prefixstr[PREFIX2STR_BUFFER], nexthopstr[128];
                prefix2str((struct prefix *)&api.prefix, prefixstr,
                           sizeof(prefixstr));
-               if (nexthop)
-                       inet_ntop(AF_INET6, nexthop, nexthopstr,
-                                 sizeof(nexthopstr));
-               else
-                       snprintf(nexthopstr, sizeof(nexthopstr), "::");
+               inet_ntop(AF_INET6, nexthop, nexthopstr, sizeof(nexthopstr));
 
                zlog_debug(
                        "Zebra Receive route %s: %s %s nexthop %s ifindex %ld tag %" ROUTE_TAG_PRI,
index 1c1c76c1afdda52e4d35bf1c6259ba1da3ece51f..55170089098553adb1e0d32dbdb0a54377646665 100644 (file)
@@ -2425,7 +2425,7 @@ DEFUN (show_ip_ospf_mpls_te_router,
                if (ntohs(OspfMplsTE.router_addr.header.type) != 0)
                        show_vty_router_addr(vty,
                                             &OspfMplsTE.router_addr.header);
-               else if (vty != NULL)
+               else
                        vty_out(vty, "  N/A\n");
        }
        return CMD_SUCCESS;
index d9b38bba89384a043482ff4acf86752426bd8e0b..36eceafd9b6f20e62edd89b9be9c92bed16f2961 100644 (file)
@@ -1685,6 +1685,7 @@ int rip_recvmsg(int sock, u_char *buf, int size, struct sockaddr_in *from,
        struct cmsghdr *ptr;
        char adata[1024];
 
+       memset(&msg, 0, sizeof(msg));
        msg.msg_name = (void *)from;
        msg.msg_namelen = sizeof(struct sockaddr_in);
        msg.msg_iov = &iov;
index 2883698f47b8bf59915dc11d7ebbcf9a5bfa5ee0..d8017622d123a6283d65dd8ba6a06d6be70cddc6 100644 (file)
@@ -176,6 +176,7 @@ int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to,
                addr.sin6_port = htons(RIPNG_PORT_DEFAULT);
        }
 
+       memset(&msg, 0, sizeof(msg));
        msg.msg_name = (void *)&addr;
        msg.msg_namelen = sizeof(struct sockaddr_in6);
        msg.msg_iov = &iov;
@@ -228,6 +229,7 @@ static int ripng_recv_packet(int sock, u_char *buf, int bufsize,
        char adata[1024];
 
        /* Fill in message and iovec. */
+       memset(&msg, 0, sizeof(msg));
        msg.msg_name = (void *)from;
        msg.msg_namelen = sizeof(struct sockaddr_in6);
        msg.msg_iov = &iov;
index 0d081551785b47c64474b6afacd33fabf4fa5ef8..ff69ce47cf2f4cd92499b0edef5fb4cc326cc51a 100644 (file)
@@ -393,7 +393,7 @@ static int get_iflink_speed(const char *ifname)
        memset(&ifdata, 0, sizeof(ifdata));
 
        /* set interface name */
-       strcpy(ifdata.ifr_name, ifname);
+       strlcpy(ifdata.ifr_name, ifname, sizeof(ifdata.ifr_name));
 
        /* initialize ethtool interface */
        memset(&ecmd, 0, sizeof(ecmd));
index c17e408ea0e062903fb19ec91a3969228f57854d..12312ff43a954954e943d9d58d45be857af6e54f 100644 (file)
@@ -493,7 +493,7 @@ void if_add_update(struct interface *ifp)
        if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
                SET_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE);
 
-               if (if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) {
+               if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) {
                        if (IS_ZEBRA_DEBUG_KERNEL)
                                zlog_debug(
                                        "interface %s vrf %u index %d is shutdown. "
index 835f1f4934c826edac851036b0889c9f6a1d7251..4404bb44830c71c79b099821a7927fcf6f539ce3 100644 (file)
@@ -44,7 +44,7 @@ extern struct zebra_privs_t zserv_privs;
 /* clear and set interface name string */
 void ifreq_set_name(struct ifreq *ifreq, struct interface *ifp)
 {
-       strncpy(ifreq->ifr_name, ifp->name, IFNAMSIZ);
+       strlcpy(ifreq->ifr_name, ifp->name, sizeof(ifreq->ifr_name));
 }
 
 /* call ioctl system call */
index 08322455368fde4b1e3104bceb48a898b5a88f97..11bc9b0440c30d80d21d0825a63be2e998fcc398 100644 (file)
@@ -182,6 +182,7 @@ static int irdp_recvmsg(int sock, u_char *buf, int size, int *ifindex)
        char adata[CMSG_SPACE(SOPT_SIZE_CMSG_PKTINFO_IPV4())];
        int ret;
 
+       memset(&msg, 0, sizeof(msg));
        msg.msg_name = (void *)0;
        msg.msg_namelen = 0;
        msg.msg_iov = &iov;
index e28fe5630aeeb53360bc073599f099e2259c498b..c2e8349bf53cbcbd559e2386f449d272df3ba425 100644 (file)
@@ -558,8 +558,8 @@ static int netlink_route_change_read_multicast(struct sockaddr_nl *snl,
 
        if (IS_ZEBRA_DEBUG_KERNEL) {
                struct interface *ifp;
-               strcpy(sbuf, inet_ntoa(m->sg.src));
-               strcpy(gbuf, inet_ntoa(m->sg.grp));
+               strlcpy(sbuf, inet_ntoa(m->sg.src), sizeof(sbuf));
+               strlcpy(gbuf, inet_ntoa(m->sg.grp), sizeof(gbuf));
                for (count = 0; count < oif_count; count++) {
                        ifp = if_lookup_by_index(oif[count], vrf);
                        char temp[256];
@@ -1553,6 +1553,8 @@ int kernel_get_ipmr_sg_stats(struct zebra_vrf *zvrf, void *in)
 int kernel_route_rib(struct prefix *p, struct prefix *src_p,
                     struct route_entry *old, struct route_entry *new)
 {
+       assert(old || new);
+
        if (!old && new)
                return netlink_route_multipath(RTM_NEWROUTE, p, src_p, new, 0);
        if (old && !new)
index 2182d6618ce4a33fa4a24c0b19a387424119cd1d..295975c5ca9813116288026b7438857e1a3fb58e 100644 (file)
@@ -107,6 +107,7 @@ static int rtadv_recv_packet(struct zebra_ns *zns, int sock, u_char *buf,
        char adata[1024];
 
        /* Fill in message and iovec. */
+       memset(&msg, 0, sizeof(msg));
        msg.msg_name = (void *)from;
        msg.msg_namelen = sizeof(struct sockaddr_in6);
        msg.msg_iov = &iov;
index cee3a03858b1d6e8f34c7e73f9a05866f558308e..3c4de40db3d4b756c2020ff5889bd8ee0c30ff4d 100644 (file)
@@ -840,7 +840,7 @@ static void lsp_schedule(struct hash_backet *backet, void *ctxt)
        zebra_lsp_t *lsp;
 
        lsp = (zebra_lsp_t *)backet->data;
-       lsp_processq_add(lsp);
+       (void)lsp_processq_add(lsp);
 }
 
 /*
@@ -2718,10 +2718,10 @@ int zebra_mpls_write_lsp_config(struct vty *vty, struct zebra_vrf *zvrf)
        for (ALL_LIST_ELEMENTS_RO(slsp_list, node, slsp)) {
                for (snhlfe = slsp->snhlfe_list; snhlfe;
                     snhlfe = snhlfe->next) {
-                       char buf[INET6_ADDRSTRLEN];
+                       char buf[BUFSIZ];
                        char lstr[30];
 
-                       snhlfe2str(snhlfe, buf, BUFSIZ);
+                       snhlfe2str(snhlfe, buf, sizeof(buf));
                        switch (snhlfe->out_label) {
                        case MPLS_V4_EXP_NULL_LABEL:
                        case MPLS_V6_EXP_NULL_LABEL:
index c4d674df23b43c9078d3baca6d5f92795135ae9a..75d5d5d6276c0167a06e9ad2a473751237301215 100644 (file)
@@ -48,8 +48,8 @@ int zebra_ipmr_route_stats(struct zserv *client, int fd, u_short length,
                char sbuf[40];
                char gbuf[40];
 
-               strcpy(sbuf, inet_ntoa(mroute.sg.src));
-               strcpy(gbuf, inet_ntoa(mroute.sg.grp));
+               strlcpy(sbuf, inet_ntoa(mroute.sg.src), sizeof(sbuf));
+               strlcpy(gbuf, inet_ntoa(mroute.sg.grp), sizeof(gbuf));
 
                zlog_debug("Asking for (%s,%s) mroute information", sbuf, gbuf);
        }
index 0b6263fac5241b2ce4b82f3d16fd493f060568d2..ce9f19c3cc22f26b471a9eacdb28c64bbbbb9c2d 100644 (file)
@@ -328,6 +328,7 @@ DEFUN_NOSH (pseudowire_if,
                if (!pw)
                        return CMD_SUCCESS;
                zebra_pw_del(zvrf, pw);
+               return CMD_SUCCESS;
        }
 
        if (!pw)
index ff140bad676835739325aa1fd059b407162843d2..82c0524a8f43b81300a44cb40e33067fdbd07aaa 100644 (file)
@@ -470,7 +470,7 @@ static int vrf_config_write(struct vty *vty)
        RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
        {
                zvrf = vrf->info;
-               if (!zvrf || strcmp(zvrf_name(zvrf), VRF_DEFAULT_NAME)) {
+               if (strcmp(zvrf_name(zvrf), VRF_DEFAULT_NAME)) {
                        vty_out(vty, "vrf %s\n", zvrf_name(zvrf));
                        vty_out(vty, "!\n");
                }
index 9f887e840189428045cfb4d16fd7cd34a3556571..7649d5f35871de51a847b2bc19447424256167e8 100644 (file)
@@ -1181,7 +1181,10 @@ DEFUN (show_ip_route,
                tag = strtoul(argv[idx + 1]->arg, NULL, 10);
 
        else if (argv_find(argv, argc, "A.B.C.D/M", &idx)) {
-               str2prefix(argv[idx]->arg, &p);
+               if (str2prefix(argv[idx]->arg, &p) <= 0) {
+                       vty_out(vty, "%% Malformed prefix\n");
+                       return CMD_WARNING;
+               }
                longer_prefixes = true;
        }
 
@@ -1834,7 +1837,10 @@ DEFUN (show_ipv6_route,
                tag = strtoul(argv[idx + 1]->arg, NULL, 10);
 
        else if (argv_find(argv, argc, "X:X::X:X/M", &idx)) {
-               str2prefix(argv[idx]->arg, &p);
+               if (str2prefix(argv[idx]->arg, &p) <= 0) {
+                       vty_out(vty, "%% Malformed prefix\n");
+                       return CMD_WARNING;
+               }
                longer_prefixes = true;
        }
 
@@ -2572,6 +2578,8 @@ DEFUN (ip_zebra_import_table_distance,
                vty_out(vty,
                        "Invalid routing table ID, %d. Must be in range 1-252\n",
                        table_id);
+               if (rmap)
+                       XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
                return CMD_WARNING;
        }
 
@@ -2579,6 +2587,8 @@ DEFUN (ip_zebra_import_table_distance,
                vty_out(vty,
                        "Invalid routing table ID, %d. Must be non-default table\n",
                        table_id);
+               if (rmap)
+                       XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
                return CMD_WARNING;
        }
 
index f99c16ae91a8586a9a256fefab5a2a94f328275d..b20ba7d9f5b335c2a5ea2610de1d8a40366ccf27 100644 (file)
@@ -1343,8 +1343,7 @@ static int zvni_gw_macip_add(struct interface *ifp, zebra_vni_t *zvni,
                        zlog_err(
                                "%u:Failed to add neighbor %s MAC %s intf %s(%u) -> VNI %u",
                                ifp->vrf_id, ipaddr2str(ip, buf2, sizeof(buf2)),
-                               prefix_mac2str(macaddr, NULL,
-                                              ETHER_ADDR_STRLEN),
+                               prefix_mac2str(macaddr, buf, sizeof(buf)),
                                ifp->name, ifp->ifindex, zvni->vni);
                        return -1;
                }
@@ -1380,6 +1379,7 @@ static int zvni_gw_macip_del(struct interface *ifp, zebra_vni_t *zvni,
        struct zebra_vrf *zvrf = NULL;
        zebra_neigh_t *n = NULL;
        zebra_mac_t *mac = NULL;
+       char buf1[ETHER_ADDR_STRLEN];
        char buf2[INET6_ADDRSTRLEN];
 
        zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id);
@@ -1393,11 +1393,13 @@ static int zvni_gw_macip_del(struct interface *ifp, zebra_vni_t *zvni,
 
        /* mac entry should be present */
        mac = zvni_mac_lookup(zvni, &n->emac);
-       if (!mac)
-               zlog_err("%u: MAC %s doesnt exsists for neigh %s on VNI %u",
+       if (!mac) {
+               zlog_err("%u: MAC %s doesnt exists for neigh %s on VNI %u",
                         ifp->vrf_id,
-                        prefix_mac2str(&n->emac, NULL, ETHER_ADDR_STRLEN),
+                        prefix_mac2str(&n->emac, buf1, sizeof(buf1)),
                         ipaddr2str(ip, buf2, sizeof(buf2)), zvni->vni);
+               return -1;
+       }
 
        /* If the entry is not local nothing to do*/
        if (!CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL))
@@ -1407,7 +1409,7 @@ static int zvni_gw_macip_del(struct interface *ifp, zebra_vni_t *zvni,
                zlog_debug(
                        "%u:SVI %s(%u) VNI %u, sending GW MAC %s IP %s del to BGP",
                        ifp->vrf_id, ifp->name, ifp->ifindex, zvni->vni,
-                       prefix_mac2str(&(n->emac), NULL, ETHER_ADDR_STRLEN),
+                       prefix_mac2str(&(n->emac), buf1, sizeof(buf1)),
                        ipaddr2str(ip, buf2, sizeof(buf2)));
 
        /* Remove neighbor from BGP. */