diff options
author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2022-02-09 15:41:14 +0100 |
---|---|---|
committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2022-02-09 15:41:14 +0100 |
commit | b7b3e63cc0ef69b30d73fd2bf1593aad665c26f5 (patch) | |
tree | 45b9765f7f395ce9a09d1796951bc7a2c8497188 /bgpd | |
parent | Merge pull request #8458 from opensourcerouting/xref-5424 (diff) | |
download | frr-b7b3e63cc0ef69b30d73fd2bf1593aad665c26f5.tar.xz frr-b7b3e63cc0ef69b30d73fd2bf1593aad665c26f5.zip |
bgpd: Check for NULL inside aspath_unintern()
It's not always guarded, just check inside.
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_aspath.c | 7 | ||||
-rw-r--r-- | bgpd/bgp_attr.c | 17 |
2 files changed, 13 insertions, 11 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index 192cd6ca8..dd27c9f6a 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -328,7 +328,12 @@ void aspath_free(struct aspath *aspath) void aspath_unintern(struct aspath **aspath) { struct aspath *ret; - struct aspath *asp = *aspath; + struct aspath *asp; + + if (!*aspath) + return; + + asp = *aspath; if (asp->refcnt) asp->refcnt--; diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 3c3fd174f..607e5152b 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1093,8 +1093,7 @@ void bgp_attr_unintern_sub(struct attr *attr) struct cluster_list *cluster; /* aspath refcount shoud be decrement. */ - if (attr->aspath) - aspath_unintern(&attr->aspath); + aspath_unintern(&attr->aspath); UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH)); if (attr->community) @@ -3534,14 +3533,12 @@ done: * we can chuck as4_aggregator and as4_path alltogether in order * to save memory */ - if (as4_path) { - /* - * unintern - it is in the hash - * The flag that we got this is still there, but that - * does not do any trouble - */ - aspath_unintern(&as4_path); - } + /* + * unintern - it is in the hash + * The flag that we got this is still there, but that + * does not do any trouble + */ + aspath_unintern(&as4_path); transit = bgp_attr_get_transit(attr); if (ret != BGP_ATTR_PARSE_ERROR) { |