mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Damato <joe@dama.to>
To: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Cc: Steen.Hegelund@microchip.com, daniel.machon@microchip.com,
	UNGLinuxDriver@microchip.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH net] net: microchip: vcap api: Fix possible memory leak in vcap_decode_rule()
Date: Mon, 27 Jul 2026 10:26:34 -0700	[thread overview]
Message-ID: <ameUygDr01/ZvnPD@devvm20253.cco0.facebook.com> (raw)
In-Reply-To: <20260727125757.134611-1-nihaal@cse.iitm.ac.in>

On Mon, Jul 27, 2026 at 06:27:55PM +0530, Abdun Nihaal wrote:
> 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 <nihaal@cse.iitm.ac.in>
> ---
> 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);
>  }

Not sure what the style guidelines say, but the label err and the local
variable err having the same name is a bit confusing.

Maybe you could make the label "out_err" and update the gotos instead?

Either way, the code looks right other than the style nit, so if you resend
you can apply my tag:

Reviewed-by: Joe Damato <joe@dama.to>

  reply	other threads:[~2026-07-27 17:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 12:57 Abdun Nihaal
2026-07-27 17:26 ` Joe Damato [this message]
2026-07-28 11:36   ` Abdun Nihaal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ameUygDr01/ZvnPD@devvm20253.cco0.facebook.com \
    --to=joe@dama.to \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nihaal@cse.iitm.ac.in \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®