summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorAbdun Nihaal <nihaal@cse.iitm.ac.in>2026-08-01 11:25:05 +0530
committerJakub Kicinski <kuba@kernel.org>2026-08-04 18:03:29 -0700
commit30ce0cb576b622f8fb5c5c9ebe43e28365374a3a (patch)
tree461f749f2a7dfd59ef98d6bb9e622e4725e7358b /drivers/net/ethernet
parent50eed72f1c7c639ec54edcb5892035b80c694df5 (diff)
downloadlinux-next-30ce0cb576b622f8fb5c5c9ebe43e28365374a3a.tar.gz
linux-next-30ce0cb576b622f8fb5c5c9ebe43e28365374a3a.zip
net: microchip: vcap api: Fix possible memory leak in vcap_decode_rule()
The memory allocated for struct vcap_rule_internal, keyfields and actionfields inside vcap_dup_rule() are not freed in some of the error paths in vcap_decode_rule(). Fix that by calling vcap_free_rule(). Compile tested only. Issue found using a prototype static analysis tool built on top of the LLVM compiler infrastructure. Cc: stable+noautosel@kernel.org # untested fix to unlikely driver error path Reviewed-by: Joe Damato <joe@dama.to> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in> Link: https://patch.msgid.link/20260801055507.47534-1-nihaal@cse.iitm.ac.in Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/microchip/vcap/vcap_api.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c
index ff86cde11a32..788c0728d763 100644
--- a/drivers/net/ethernet/microchip/vcap/vcap_api.c
+++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c
@@ -2427,18 +2427,21 @@ struct vcap_rule *vcap_decode_rule(struct vcap_rule_internal *elem)
err = vcap_read_rule(ri);
if (err)
- return ERR_PTR(err);
+ goto err_free_rule;
err = vcap_decode_keyset(ri);
if (err)
- return ERR_PTR(err);
+ goto err_free_rule;
err = vcap_decode_actionset(ri);
if (err)
- return ERR_PTR(err);
+ goto err_free_rule;
out:
return &ri->data;
+err_free_rule:
+ vcap_free_rule(&ri->data);
+ return ERR_PTR(err);
}
struct vcap_rule *vcap_get_rule(struct vcap_control *vctrl, u32 id)