Skip to content

Commit

Permalink
zebra: Prevent accidental re memory leak in odd case
Browse files Browse the repository at this point in the history
There exists a path in rib_add_multipath where if a decision
is made to not use the passed in re, we just drop the memory
instead of freeing it.  Let's free it.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Jun 27, 2024
1 parent 47ad9b3 commit e506c59
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion zebra/zebra_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4365,8 +4365,10 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
return -1;

/* We either need nexthop(s) or an existing nexthop id */
if (ng == NULL && re->nhe_id == 0)
if (ng == NULL && re->nhe_id == 0) {
XFREE(MTYPE_RE, re);
return -1;
}

/*
* Use a temporary nhe to convey info to the common/main api.
Expand Down

0 comments on commit e506c59

Please sign in to comment.