Skip to content

Commit 78beef6

Browse files
Navidemdavem330
authored andcommitted
nfp: abm: fix memory leak in nfp_abm_u32_knode_replace
In nfp_abm_u32_knode_replace if the allocation for match fails it should go to the error handling instead of returning. Updated other gotos to have correct errno returned, too. Signed-off-by: Navid Emamdoost <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a41e8a8 commit 78beef6

File tree

1 file changed

+10
-4
lines changed
  • drivers/net/ethernet/netronome/nfp/abm

1 file changed

+10
-4
lines changed

drivers/net/ethernet/netronome/nfp/abm/cls.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink,
176176
u8 mask, val;
177177
int err;
178178

179-
if (!nfp_abm_u32_check_knode(alink->abm, knode, proto, extack))
179+
if (!nfp_abm_u32_check_knode(alink->abm, knode, proto, extack)) {
180+
err = -EOPNOTSUPP;
180181
goto err_delete;
182+
}
181183

182184
tos_off = proto == htons(ETH_P_IP) ? 16 : 20;
183185

@@ -198,14 +200,18 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink,
198200
if ((iter->val & cmask) == (val & cmask) &&
199201
iter->band != knode->res->classid) {
200202
NL_SET_ERR_MSG_MOD(extack, "conflict with already offloaded filter");
203+
err = -EOPNOTSUPP;
201204
goto err_delete;
202205
}
203206
}
204207

205208
if (!match) {
206209
match = kzalloc(sizeof(*match), GFP_KERNEL);
207-
if (!match)
208-
return -ENOMEM;
210+
if (!match) {
211+
err = -ENOMEM;
212+
goto err_delete;
213+
}
214+
209215
list_add(&match->list, &alink->dscp_map);
210216
}
211217
match->handle = knode->handle;
@@ -221,7 +227,7 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink,
221227

222228
err_delete:
223229
nfp_abm_u32_knode_delete(alink, knode);
224-
return -EOPNOTSUPP;
230+
return err;
225231
}
226232

227233
static int nfp_abm_setup_tc_block_cb(enum tc_setup_type type,

0 commit comments

Comments
 (0)