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(). Fixes: 610c32b2ce66 ("net: microchip: vcap: Add vcap_get_rule") Cc: stable@vger.kernel.org Signed-off-by: Abdun Nihaal --- Compile tested only. Issue found using static analysis. drivers/net/ethernet/microchip/vcap/vcap_api.c | 9 ++++++--- 1 file 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..0cc0db7b641b 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; err = vcap_decode_keyset(ri); if (err) - return ERR_PTR(err); + goto err; err = vcap_decode_actionset(ri); if (err) - return ERR_PTR(err); + goto err; out: return &ri->data; +err: + vcap_free_rule(&ri->data); + return ERR_PTR(err); } struct vcap_rule *vcap_get_rule(struct vcap_control *vctrl, u32 id) -- 2.43.0