From c415a4dcd4f5651ed3e2668f5f88e7d8cbe55fb6 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 8 Jun 2020 14:58:53 +0300 Subject: lib: Make sure route_map_dep_data is not NULL before decrementing refcount ``` 2 0x00007fb9adb07a10 in core_handler (signo=11, siginfo=0x7ffe1414a630, context=) at lib/sigevent.c:228 sa_default = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 }}, sa_flags = 0, sa_restorer = 0x0} sigset = {__val = {8192, 0 }} 3 No locals. 4 route_map_dep_update (type=RMAP_EVENT_CLIST_DELETED, rmap_name=0x55d807ddd410 "export4-as49917", dep_name=, dephash=0x55d807adf170) at lib/routemap.c:2750 dep = 0x55d807d35b00 dname = 0x55d8081ba560 "123:124" rname = 0x55d8081ba540 "export4-as49917" ret = 0 dep_data = 0x0 ret_dep_data = 0x0 tmp_dep_data = {rname = 0x55d8081ba540 "export4-as49917", refcnt = 0} 5 route_map_upd8_dependency (type=RMAP_EVENT_CLIST_DELETED, arg=, rmap_name=0x55d807ddd410 "export4-as49917") at lib/routemap.c:2865 upd8_hash = 0x55d807adf170 ``` Signed-off-by: Donatas Abraitis --- lib/routemap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/routemap.c') diff --git a/lib/routemap.c b/lib/routemap.c index 210512212..3d69a3495 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -2747,7 +2747,12 @@ static int route_map_dep_update(struct hash *dephash, const char *dep_name, memset(&tmp_dep_data, 0, sizeof(struct route_map_dep_data)); tmp_dep_data.rname = rname; dep_data = hash_lookup(dep->dep_rmap_hash, &tmp_dep_data); - dep_data->refcnt--; + + if (!dep_data) + goto out; + + if (dep_data->refcnt) + dep_data->refcnt--; if (!dep_data->refcnt) { ret_dep_data = hash_release(dep->dep_rmap_hash, -- cgit v1.2.3