diff options
Diffstat (limited to 'lib/route/cls/basic.c')
-rw-r--r-- | lib/route/cls/basic.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/route/cls/basic.c b/lib/route/cls/basic.c index 5a67fae..6af3844 100644 --- a/lib/route/cls/basic.c +++ b/lib/route/cls/basic.c @@ -228,6 +228,8 @@ int rtnl_basic_add_action(struct rtnl_cls *cls, struct rtnl_act *act) return -NLE_NOMEM; b->b_mask |= BASIC_ATTR_ACTION; + /* In case user frees it */ + rtnl_act_get(act); return rtnl_act_append(&b->b_act, act); } @@ -245,9 +247,13 @@ int rtnl_basic_del_action(struct rtnl_cls *cls, struct rtnl_act *act) if (!(b->b_mask & BASIC_ATTR_ACTION)) return -NLE_INVAL; ret = rtnl_act_remove(&b->b_act, act); + if (ret) + return ret; + if (!b->b_act) b->b_mask &= ~BASIC_ATTR_ACTION; - return ret; + rtnl_act_put(act); + return 0; } /** @} */ |