Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Zhipeng Lu and committed by
David S. Miller
f3616173 d75abeec

+2
+2
drivers/atm/idt77252.c
··· 2930 2930 vc->scq = alloc_scq(card, vc->class); 2931 2931 if (!vc->scq) { 2932 2932 printk("%s: can't get SCQ.\n", card->name); 2933 + kfree(card->vcs[0]); 2934 + card->vcs[0] = NULL; 2933 2935 return -ENOMEM; 2934 2936 } 2935 2937