netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] atm: idt77252: fix a memleak in open_card_ubr0
@ 2024-02-01 12:41 Zhipeng Lu
  2024-02-01 13:29 ` Jiri Pirko
  2024-02-03 12:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Zhipeng Lu @ 2024-02-01 12:41 UTC (permalink / raw)
  To: alexious; +Cc: Chas Williams, linux-atm-general, netdev, linux-kernel

When alloc_scq fails, card->vcs[0] (i.e. vc) should be freed. Otherwise,
in the following call chain:

idt77252_init_one
  |-> idt77252_dev_open
        |-> open_card_ubr0
              |-> alloc_scq [failed]
  |-> deinit_card
        |-> vfree(card->vcs);

card->vcs is freed and card->vcs[0] is leaked.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
---
 drivers/atm/idt77252.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index e327a0229dc1..e7f713cd70d3 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -2930,6 +2930,8 @@ open_card_ubr0(struct idt77252_dev *card)
 	vc->scq = alloc_scq(card, vc->class);
 	if (!vc->scq) {
 		printk("%s: can't get SCQ.\n", card->name);
+		kfree(card->vcs[0]);
+		card->vcs[0] = NULL;
 		return -ENOMEM;
 	}
 
-- 
2.34.1


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

* Re: [PATCH] atm: idt77252: fix a memleak in open_card_ubr0
  2024-02-01 12:41 [PATCH] atm: idt77252: fix a memleak in open_card_ubr0 Zhipeng Lu
@ 2024-02-01 13:29 ` Jiri Pirko
  2024-02-03 12:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2024-02-01 13:29 UTC (permalink / raw)
  To: Zhipeng Lu; +Cc: Chas Williams, linux-atm-general, netdev, linux-kernel

Thu, Feb 01, 2024 at 01:41:05PM CET, alexious@zju.edu.cn wrote:
>When alloc_scq fails, card->vcs[0] (i.e. vc) should be freed. Otherwise,
>in the following call chain:
>
>idt77252_init_one
>  |-> idt77252_dev_open
>        |-> open_card_ubr0
>              |-> alloc_scq [failed]
>  |-> deinit_card
>        |-> vfree(card->vcs);
>
>card->vcs is freed and card->vcs[0] is leaked.
>
>Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>

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

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

* Re: [PATCH] atm: idt77252: fix a memleak in open_card_ubr0
  2024-02-01 12:41 [PATCH] atm: idt77252: fix a memleak in open_card_ubr0 Zhipeng Lu
  2024-02-01 13:29 ` Jiri Pirko
@ 2024-02-03 12:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-03 12:50 UTC (permalink / raw)
  To: Zhipeng Lu; +Cc: 3chas3, linux-atm-general, 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:41:05 +0800 you wrote:
> When alloc_scq fails, card->vcs[0] (i.e. vc) should be freed. Otherwise,
> in the following call chain:
> 
> idt77252_init_one
>   |-> idt77252_dev_open
>         |-> open_card_ubr0
>               |-> alloc_scq [failed]
>   |-> deinit_card
>         |-> vfree(card->vcs);
> 
> [...]

Here is the summary with links:
  - atm: idt77252: fix a memleak in open_card_ubr0
    https://git.kernel.org/netdev/net/c/f3616173bf9b

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] 3+ messages in thread

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01 12:41 [PATCH] atm: idt77252: fix a memleak in open_card_ubr0 Zhipeng Lu
2024-02-01 13:29 ` Jiri Pirko
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).