From c4097b758e5d13fbd01306167079ab608165ec3a Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Tue, 15 Oct 2019 13:42:15 -0400 Subject: [PATCH] zebra: Only free if rule was found/release in table We were seeing a double free on shutdown if the hash release fails here due to the interface state changing. We probably shouldn't free the data if its still being handled in the table so adding a check there and a debug message. Signed-off-by: Stephen Worley --- zebra/zebra_pbr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index f95a4ff950..9a7d506731 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -471,8 +471,12 @@ static void zebra_pbr_cleanup_rules(struct hash_bucket *b, void *data) if (rule->sock == *sock) { (void)kernel_del_pbr_rule(rule); - hash_release(zrouter.rules_hash, rule); - XFREE(MTYPE_TMP, rule); + if (hash_release(zrouter.rules_hash, rule)) + XFREE(MTYPE_TMP, rule); + else + zlog_debug( + "%s: Rule seq: %u is being cleaned but we can't find it in our tables", + __func__, rule->rule.seq); } }