Skip to content

Commit

Permalink
net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
José Expósito authored and Jakub Kicinski committed Dec 9, 2021
1 parent 37ad4e2 commit e8b1d76
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/dsa/ocelot/felix.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,11 @@ static int felix_setup_mmio_filtering(struct felix *felix)
}
}

if (cpu < 0)
if (cpu < 0) {
kfree(tagging_rule);
kfree(redirect_rule);
return -EINVAL;
}

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

0 comments on commit e8b1d76

Please sign in to comment.