netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] octeontx2-pf: Fix a memleak otx2_sq_init
@ 2024-02-01 12:47 Zhipeng Lu
  2024-02-01 14:01 ` Jiri Pirko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Zhipeng Lu @ 2024-02-01 12:47 UTC (permalink / raw)
  To: alexious
  Cc: Sunil Goutham, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jesse Brandeburg, Richard Cochran, netdev, linux-kernel

When qmem_alloc and pfvf->hw_ops->sq_aq_init fails, sq->sg should be
freed to prevent memleak.

Fixes: c9c12d339d93 ("octeontx2-pf: Add support for PTP clock")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
---
 .../ethernet/marvell/octeontx2/nic/otx2_common.c   | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
index 7ca6941ea0b9..02d0b707aea5 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
@@ -951,8 +951,11 @@ int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
 	if (pfvf->ptp && qidx < pfvf->hw.tx_queues) {
 		err = qmem_alloc(pfvf->dev, &sq->timestamps, qset->sqe_cnt,
 				 sizeof(*sq->timestamps));
-		if (err)
+		if (err) {
+			kfree(sq->sg);
+			sq->sg = NULL;
 			return err;
+		}
 	}
 
 	sq->head = 0;
@@ -968,7 +971,14 @@ int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
 	sq->stats.bytes = 0;
 	sq->stats.pkts = 0;
 
-	return pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura);
+	err = pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura);
+	if (err) {
+		kfree(sq->sg);
+		sq->sg = NULL;
+		return err;
+	}
+
+	return 0;
 
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] octeontx2-pf: Fix a memleak otx2_sq_init
  2024-02-01 12:47 [PATCH] octeontx2-pf: Fix a memleak otx2_sq_init Zhipeng Lu
@ 2024-02-01 14:01 ` Jiri Pirko
  2024-02-02  5:01 ` [EXT] " Subbaraya Sundeep Bhatta
  2024-02-03 12:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2024-02-01 14:01 UTC (permalink / raw)
  To: Zhipeng Lu
  Cc: Sunil Goutham, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jesse Brandeburg, Richard Cochran, netdev, linux-kernel

Thu, Feb 01, 2024 at 01:47:13PM CET, alexious@zju.edu.cn wrote:
>When qmem_alloc and pfvf->hw_ops->sq_aq_init fails, sq->sg should be
>freed to prevent memleak.
>
>Fixes: c9c12d339d93 ("octeontx2-pf: Add support for PTP clock")
>Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>

Acked-by: Jiri Pirko <jiri@nvidia.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [EXT] [PATCH] octeontx2-pf: Fix a memleak otx2_sq_init
  2024-02-01 12:47 [PATCH] octeontx2-pf: Fix a memleak otx2_sq_init Zhipeng Lu
  2024-02-01 14:01 ` Jiri Pirko
@ 2024-02-02  5:01 ` Subbaraya Sundeep Bhatta
  2024-02-03 12:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Subbaraya Sundeep Bhatta @ 2024-02-02  5:01 UTC (permalink / raw)
  To: Zhipeng Lu
  Cc: Sunil Kovvuri Goutham, Geethasowjanya Akula, Hariprasad Kelam,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jesse Brandeburg, Richard Cochran, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org

Looks good to me.

Thanks,
Sundeep

>-----Original Message-----
>From: Zhipeng Lu <alexious@zju.edu.cn>
>Sent: Thursday, February 1, 2024 6:17 PM
>To: alexious@zju.edu.cn
>Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>; Geethasowjanya Akula
><gakula@marvell.com>; Subbaraya Sundeep Bhatta <sbhatta@marvell.com>;
>Hariprasad Kelam <hkelam@marvell.com>; David S. Miller
><davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski
><kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Jesse Brandeburg
><jesse.brandeburg@intel.com>; Richard Cochran <richardcochran@gmail.com>;
>netdev@vger.kernel.org; linux-kernel@vger.kernel.org
>Subject: [EXT] [PATCH] octeontx2-pf: Fix a memleak otx2_sq_init
>
>External Email
>
>----------------------------------------------------------------------
>When qmem_alloc and pfvf->hw_ops->sq_aq_init fails, sq->sg should be freed to
>prevent memleak.
>
>Fixes: c9c12d339d93 ("octeontx2-pf: Add support for PTP clock")
>Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
>---
> .../ethernet/marvell/octeontx2/nic/otx2_common.c   | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
>b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
>index 7ca6941ea0b9..02d0b707aea5 100644
>--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
>+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
>@@ -951,8 +951,11 @@ int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16
>sqb_aura)
> 	if (pfvf->ptp && qidx < pfvf->hw.tx_queues) {
> 		err = qmem_alloc(pfvf->dev, &sq->timestamps, qset->sqe_cnt,
> 				 sizeof(*sq->timestamps));
>-		if (err)
>+		if (err) {
>+			kfree(sq->sg);
>+			sq->sg = NULL;
> 			return err;
>+		}
> 	}
>
> 	sq->head = 0;
>@@ -968,7 +971,14 @@ int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16
>sqb_aura)
> 	sq->stats.bytes = 0;
> 	sq->stats.pkts = 0;
>
>-	return pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura);
>+	err = pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura);
>+	if (err) {
>+		kfree(sq->sg);
>+		sq->sg = NULL;
>+		return err;
>+	}
>+
>+	return 0;
>
> }
>
>--
>2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] octeontx2-pf: Fix a memleak otx2_sq_init
  2024-02-01 12:47 [PATCH] octeontx2-pf: Fix a memleak otx2_sq_init Zhipeng Lu
  2024-02-01 14:01 ` Jiri Pirko
  2024-02-02  5:01 ` [EXT] " Subbaraya Sundeep Bhatta
@ 2024-02-03 12:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-03 12:50 UTC (permalink / raw)
  To: Zhipeng Lu
  Cc: sgoutham, gakula, sbhatta, hkelam, davem, edumazet, kuba, pabeni,
	jesse.brandeburg, richardcochran, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu,  1 Feb 2024 20:47:13 +0800 you wrote:
> When qmem_alloc and pfvf->hw_ops->sq_aq_init fails, sq->sg should be
> freed to prevent memleak.
> 
> Fixes: c9c12d339d93 ("octeontx2-pf: Add support for PTP clock")
> Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
> ---
>  .../ethernet/marvell/octeontx2/nic/otx2_common.c   | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)

Here is the summary with links:
  - octeontx2-pf: Fix a memleak otx2_sq_init
    https://git.kernel.org/netdev/net/c/b09b58e31b0f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-03 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01 12:47 [PATCH] octeontx2-pf: Fix a memleak otx2_sq_init Zhipeng Lu
2024-02-01 14:01 ` Jiri Pirko
2024-02-02  5:01 ` [EXT] " Subbaraya Sundeep Bhatta
2024-02-03 12:50 ` patchwork-bot+netdevbpf

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).