diff mbox series

atm: idt77252: fix a memleak in open_card_ubr0

Message ID 20240201124108.3052635-1-alexious@zju.edu.cn (mailing list archive)
State Accepted
Commit f3616173bf9be9bf39d131b120d6eea4e6324cb5
Headers show
Series atm: idt77252: fix a memleak in open_card_ubr0 | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1075 this patch: 1075
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1065 this patch: 1065
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1092 this patch: 1092
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-02--15-00 (tests: 720)

Commit Message

Zhipeng Lu Feb. 1, 2024, 12:41 p.m. UTC
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(+)

Comments

Jiri Pirko Feb. 1, 2024, 1:29 p.m. UTC | #1
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>
patchwork-bot+netdevbpf@kernel.org Feb. 3, 2024, 12:50 p.m. UTC | #2
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!
diff mbox series

Patch

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;
 	}