Skip to contentSkip to conversation

atm: idt77252: fix a memleak in open_card_ubr0

PATCH Applied Zhipeng Lu 3 participants 3 messages Feb 1, 2024 – Feb 3, 2024

Subsystems (3)
lore
Share & tools
lore

Zhipeng Lu

author
#0 lore raw

PATCH 1/1 atm: idt77252: fix a memleak in open_card_ubr0

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")
---
 drivers/atm/idt77252.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/atm/idt77252.c +2 -0
index e327a0229dc1..e7f713cd70d3 100644
@@ -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;
 	}
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Thu, Feb 01, 2024 at 01:41:05PM CET, [email protected] 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);
Quoted 4 lines

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

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
#2 lore raw
In reply to Zhipeng Lu
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 11 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html