From: Rasmus Villemoes Date: Thu, 8 Jun 2017 08:59:22 +0000 (+0200) Subject: lib/route/cls/u32.c: remove pointless nl_data_append calls X-Git-Tag: libnl3_4_0rc1~7^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2fda8661fd55e747d44974054b73bb66153aeb59;p=libnl lib/route/cls/u32.c: remove pointless nl_data_append calls Increasing the size of the u->cu_selector item by the size of a struct tc_u32_key (i.e., making the flexible array member sel->keys one element bigger) is pointless when one doesn't update sel->nkeys or otherwise records the increased size, so these are effectively memory leaks. --- diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c index 087797e..6b2c66d 100644 --- a/lib/route/cls/u32.c +++ b/lib/route/cls/u32.c @@ -469,7 +469,6 @@ int rtnl_u32_set_hashmask(struct rtnl_cls *cls, uint32_t hashmask, uint32_t offs { struct rtnl_u32 *u; struct tc_u32_sel *sel; - int err; hashmask = htonl(hashmask); @@ -480,12 +479,6 @@ int rtnl_u32_set_hashmask(struct rtnl_cls *cls, uint32_t hashmask, uint32_t offs if (!sel) return -NLE_NOMEM; - err = nl_data_append(u->cu_selector, NULL, sizeof(struct tc_u32_key)); - if(err < 0) - return err; - - sel = u32_selector(u); - sel->hmask = hashmask; sel->hoff = offset; return 0; @@ -495,7 +488,6 @@ int rtnl_u32_set_selector(struct rtnl_cls *cls, int offoff, uint32_t offmask, ch { struct rtnl_u32 *u; struct tc_u32_sel *sel; - int err; offmask = ntohs(offmask); @@ -506,12 +498,6 @@ int rtnl_u32_set_selector(struct rtnl_cls *cls, int offoff, uint32_t offmask, ch if (!sel) return -NLE_NOMEM; - err = nl_data_append(u->cu_selector, NULL, sizeof(struct tc_u32_key)); - if(err < 0) - return err; - - sel = u32_selector(u); - sel->offoff = offoff; sel->offmask = offmask; sel->offshift = offshift; @@ -525,7 +511,6 @@ int rtnl_u32_set_cls_terminal(struct rtnl_cls *cls) { struct rtnl_u32 *u; struct tc_u32_sel *sel; - int err; if (!(u = (struct rtnl_u32 *) rtnl_tc_data(TC_CAST(cls)))) return -NLE_NOMEM; @@ -534,12 +519,6 @@ int rtnl_u32_set_cls_terminal(struct rtnl_cls *cls) if (!sel) return -NLE_NOMEM; - err = nl_data_append(u->cu_selector, NULL, sizeof(struct tc_u32_key)); - if(err < 0) - return err; - - sel = u32_selector(u); - sel->flags |= TC_U32_TERMINAL; return 0; }