public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH] cassini: Fix a memory leak in the error handling path of cas_init_one()
@ 2023-05-15 19:09 Christophe JAILLET
  2023-05-16  7:38 ` Pavan Chebbi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christophe JAILLET @ 2023-05-15 19:09 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jaswinder Singh, Andrew Morton
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev

cas_saturn_firmware_init() allocates some memory using vmalloc(). This
memory is freed in the .remove() function but not it the error handling
path of the probe.

Add the missing vfree() to avoid a memory leak, should an error occur.

Fixes: fcaa40669cd7 ("cassini: use request_firmware")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo•fr>
---
 drivers/net/ethernet/sun/cassini.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 2d52f54ebb45..b317b9486455 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5073,6 +5073,8 @@ static int cas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		cas_shutdown(cp);
 	mutex_unlock(&cp->pm_mutex);
 
+	vfree(cp->fw_data);
+
 	pci_iounmap(pdev, cp->regs);
 
 
-- 
2.34.1


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

* Re: [PATCH] cassini: Fix a memory leak in the error handling path of cas_init_one()
  2023-05-15 19:09 [PATCH] cassini: Fix a memory leak in the error handling path of cas_init_one() Christophe JAILLET
@ 2023-05-16  7:38 ` Pavan Chebbi
  2023-05-16 10:44 ` Simon Horman
  2023-05-17  8:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Pavan Chebbi @ 2023-05-16  7:38 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jaswinder Singh, Andrew Morton, linux-kernel, kernel-janitors,
	netdev

[-- Attachment #1: Type: text/plain, Size: 1200 bytes --]

On Tue, May 16, 2023 at 12:39 AM Christophe JAILLET
<christophe.jaillet@wanadoo•fr> wrote:
>
> cas_saturn_firmware_init() allocates some memory using vmalloc(). This
> memory is freed in the .remove() function but not it the error handling
> path of the probe.
>
> Add the missing vfree() to avoid a memory leak, should an error occur.
>
> Fixes: fcaa40669cd7 ("cassini: use request_firmware")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo•fr>
> ---
>  drivers/net/ethernet/sun/cassini.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Looks good to me, though patch could have "net" in the subject.
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom•com>


> diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
> index 2d52f54ebb45..b317b9486455 100644
> --- a/drivers/net/ethernet/sun/cassini.c
> +++ b/drivers/net/ethernet/sun/cassini.c
> @@ -5073,6 +5073,8 @@ static int cas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>                 cas_shutdown(cp);
>         mutex_unlock(&cp->pm_mutex);
>
> +       vfree(cp->fw_data);
> +
>         pci_iounmap(pdev, cp->regs);
>
>
> --
> 2.34.1
>
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* Re: [PATCH] cassini: Fix a memory leak in the error handling path of cas_init_one()
  2023-05-15 19:09 [PATCH] cassini: Fix a memory leak in the error handling path of cas_init_one() Christophe JAILLET
  2023-05-16  7:38 ` Pavan Chebbi
@ 2023-05-16 10:44 ` Simon Horman
  2023-05-17  8:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-05-16 10:44 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jaswinder Singh, Andrew Morton, linux-kernel, kernel-janitors,
	netdev

On Mon, May 15, 2023 at 09:09:11PM +0200, Christophe JAILLET wrote:
> cas_saturn_firmware_init() allocates some memory using vmalloc(). This
> memory is freed in the .remove() function but not it the error handling
> path of the probe.
> 
> Add the missing vfree() to avoid a memory leak, should an error occur.
> 
> Fixes: fcaa40669cd7 ("cassini: use request_firmware")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo•fr>

Reviewed-by: Simon Horman <simon.horman@corigine•com>


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

* Re: [PATCH] cassini: Fix a memory leak in the error handling path of cas_init_one()
  2023-05-15 19:09 [PATCH] cassini: Fix a memory leak in the error handling path of cas_init_one() Christophe JAILLET
  2023-05-16  7:38 ` Pavan Chebbi
  2023-05-16 10:44 ` Simon Horman
@ 2023-05-17  8:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-17  8:10 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: davem, edumazet, kuba, pabeni, jaswinder, akpm, linux-kernel,
	kernel-janitors, netdev

Hello:

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

On Mon, 15 May 2023 21:09:11 +0200 you wrote:
> cas_saturn_firmware_init() allocates some memory using vmalloc(). This
> memory is freed in the .remove() function but not it the error handling
> path of the probe.
> 
> Add the missing vfree() to avoid a memory leak, should an error occur.
> 
> Fixes: fcaa40669cd7 ("cassini: use request_firmware")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo•fr>
> 
> [...]

Here is the summary with links:
  - cassini: Fix a memory leak in the error handling path of cas_init_one()
    https://git.kernel.org/netdev/net/c/412cd77a2c24

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:[~2023-05-17  8:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 19:09 [PATCH] cassini: Fix a memory leak in the error handling path of cas_init_one() Christophe JAILLET
2023-05-16  7:38 ` Pavan Chebbi
2023-05-16 10:44 ` Simon Horman
2023-05-17  8:10 ` 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