Skip to content

Commit e8b1d76

Browse files
JoseExpositokuba-moo
authored andcommitted
net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering
Avoid a memory leak if there is not a CPU port defined. Fixes: 8d5f795 ("net: dsa: felix: break at first CPU port during init and teardown") Addresses-Coverity-ID: 1492897 ("Resource leak") Addresses-Coverity-ID: 1492899 ("Resource leak") Signed-off-by: José Expósito <jose.exposito89@gmail.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://lore.kernel.org/r/20211209110538.11585-1-jose.exposito89@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 37ad4e2 commit e8b1d76

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/net/dsa/ocelot/felix.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,11 @@ static int felix_setup_mmio_filtering(struct felix *felix)
290290
}
291291
}
292292

293-
if (cpu < 0)
293+
if (cpu < 0) {
294+
kfree(tagging_rule);
295+
kfree(redirect_rule);
294296
return -EINVAL;
297+
}
295298

296299
tagging_rule->key_type = OCELOT_VCAP_KEY_ETYPE;
297300
*(__be16 *)tagging_rule->key.etype.etype.value = htons(ETH_P_1588);

0 commit comments

Comments
 (0)