From: José Expósito Date: Thu, 9 Dec 2021 11:05:40 +0000 (+0100) Subject: net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=973a0373e88cc19129bd6ef0ec193040535397d9;p=linux.git net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering commit e8b1d7698038e76363859fb47ae0a262080646f5 upstream. Avoid a memory leak if there is not a CPU port defined. Fixes: 8d5f7954b7c8 ("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 Reviewed-by: Vladimir Oltean Link: https://lore.kernel.org/r/20211209110538.11585-1-jose.exposito89@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 6873d5a253afb..1513dfb523de7 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -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);