linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denis Kirjanov <dkirjanov@suse.de>
To: Q1IQ <fufuyqqqqqq@gmail.com>,
	ioana.ciornei@nxp.com, davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lyz_cs@pku.edu.cn
Subject: Re: [PATCH] dpaa2 ethernet switch driver: Fix memory leak in dpaa2_switch_acl_entry_add()
Date: Tue, 1 Mar 2022 15:14:16 +0300	[thread overview]
Message-ID: <a87a691a-62c2-5b42-3be8-ee1161281ad8@suse.de> (raw)
In-Reply-To: <20220301093444.66863-1-fufuyqqqqqq@gmail.com>



3/1/22 12:34, Q1IQ пишет:
> [why]
> The error handling branch did not properly free the memory of cmd_buf
> before return, which would cause memory leak.
> 
> [how]
> Fix this by adding kfree to the error handling branch.
> 
> Signed-off-by: Q1IQ <fufuyqqqqqq@gmail.com>

You should use your real name and please add Fixes tag

> ---
>   drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c
> index cacd454ac696..4d07aee07f4c 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c
> @@ -132,6 +132,7 @@ int dpaa2_switch_acl_entry_add(struct dpaa2_switch_filter_block *filter_block,
>   						 DMA_TO_DEVICE);
>   	if (unlikely(dma_mapping_error(dev, acl_entry_cfg->key_iova))) {
>   		dev_err(dev, "DMA mapping failed\n");
> +		kfree(cmd_buff);
>   		return -EFAULT;
>   	}
>   
> @@ -142,6 +143,7 @@ int dpaa2_switch_acl_entry_add(struct dpaa2_switch_filter_block *filter_block,
>   			 DMA_TO_DEVICE);
>   	if (err) {
>   		dev_err(dev, "dpsw_acl_add_entry() failed %d\n", err);
> +		kfree(cmd_buff);
>   		return err;
>   	}
>   

  reply	other threads:[~2022-03-01 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  9:34 [PATCH] dpaa2 ethernet switch driver: Fix memory leak in dpaa2_switch_acl_entry_add() Q1IQ
2022-03-01 12:14 ` Denis Kirjanov [this message]
2022-03-01 14:15   ` [PATCH v1] dpaa2-switch: fix memory leak of dpaa2_switch_acl_entry_add Yeqi Fu
2022-03-01 17:03     ` Ioana Ciornei
2022-03-02  1:41     ` Jakub Kicinski

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=a87a691a-62c2-5b42-3be8-ee1161281ad8@suse.de \
    --to=dkirjanov@suse.de \
    --cc=davem@davemloft.net \
    --cc=fufuyqqqqqq@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyz_cs@pku.edu.cn \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).