diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2020-06-10 13:57:02 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-10 13:57:02 -0400 |
| commit | 10658ad30b1df0d7d4ea828e4935075698eb2488 (patch) | |
| tree | e9d1459bb535d5bbc7db06be3bdba165bf7536e2 /zebra/zebra_rnh.c | |
| parent | 05e0e7dddc37cd6c7a544b10733755ba2f4d5712 (diff) | |
| parent | 2896f40e698943648e7760cd4e5e1d3c754bb3b7 (diff) | |
Merge pull request #6528 from mjstapp/fix_zebra_mpls_sa
zebra: fix coverity SA warnings
Diffstat (limited to 'zebra/zebra_rnh.c')
| -rw-r--r-- | zebra/zebra_rnh.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index ad2e00b1ec..e94a445098 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -1001,12 +1001,13 @@ static int compare_state(struct route_entry *r1, struct route_entry *r2) static int send_client(struct rnh *rnh, struct zserv *client, enum rnh_type type, vrf_id_t vrf_id) { - struct stream *s; + struct stream *s = NULL; struct route_entry *re; unsigned long nump; uint8_t num; struct nexthop *nh; struct route_node *rn; + int ret; int cmd = (type == RNH_IMPORT_CHECK_TYPE) ? ZEBRA_IMPORT_CHECK_UPDATE : ZEBRA_NEXTHOP_UPDATE; @@ -1032,7 +1033,7 @@ static int send_client(struct rnh *rnh, struct zserv *client, flog_err(EC_ZEBRA_RNH_UNKNOWN_FAMILY, "%s: Unknown family (%d) notification attempted\n", __func__, rn->p.family); - break; + goto failure; } if (re) { struct zapi_nexthop znh; @@ -1047,7 +1048,10 @@ static int send_client(struct rnh *rnh, struct zserv *client, for (ALL_NEXTHOPS(re->nhe->nhg, nh)) if (rnh_nexthop_valid(re, nh)) { zapi_nexthop_from_nexthop(&znh, nh); - zapi_nexthop_encode(s, &znh, 0 /* flags */); + ret = zapi_nexthop_encode(s, &znh, 0/*flags*/); + if (ret < 0) + goto failure; + num++; } stream_putc_at(s, nump, num); @@ -1063,6 +1067,11 @@ static int send_client(struct rnh *rnh, struct zserv *client, client->nh_last_upd_time = monotime(NULL); client->last_write_cmd = cmd; return zserv_send_message(client, s); + +failure: + if (s) + stream_free(s); + return -1; } static void print_nh(struct nexthop *nexthop, struct vty *vty) |
