Skip to content

Commit 4fe3c88

Browse files
Li Zetaokuba-moo
authored andcommitted
atm: idt77252: fix kmemleak when rmmod idt77252
There are memory leaks reported by kmemleak: unreferenced object 0xffff888106500800 (size 128): comm "modprobe", pid 1017, jiffies 4297787785 (age 67.152s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000970ce626>] __kmem_cache_alloc_node+0x20c/0x380 [<00000000fb5f78d9>] kmalloc_trace+0x2f/0xb0 [<000000000e947e2a>] idt77252_init_one+0x2847/0x3c90 [idt77252] [<000000006efb048e>] local_pci_probe+0xeb/0x1a0 ... unreferenced object 0xffff888106500b00 (size 128): comm "modprobe", pid 1017, jiffies 4297787785 (age 67.152s) hex dump (first 32 bytes): 00 20 3d 01 80 88 ff ff 00 20 3d 01 80 88 ff ff . =...... =..... f0 23 3d 01 80 88 ff ff 00 20 3d 01 00 00 00 00 .#=...... =..... backtrace: [<00000000970ce626>] __kmem_cache_alloc_node+0x20c/0x380 [<00000000fb5f78d9>] kmalloc_trace+0x2f/0xb0 [<00000000f451c5be>] alloc_scq.constprop.0+0x4a/0x400 [idt77252] [<00000000e6313849>] idt77252_init_one+0x28cf/0x3c90 [idt77252] The root cause is traced to the vc_maps which alloced in open_card_oam() are not freed in close_card_oam(). The vc_maps are used to record open connections, so when close a vc_map in close_card_oam(), the memory should be freed. Moreover, the ubr0 is not closed when close a idt77252 device, leading to the memory leak of vc_map and scq_info. Fix them by adding kfree in close_card_oam() and implementing new close_card_ubr0() to close ubr0. Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Li Zetao <[email protected]> Reviewed-by: Francois Romieu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 032a954 commit 4fe3c88

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/atm/idt77252.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,6 +2909,7 @@ close_card_oam(struct idt77252_dev *card)
29092909

29102910
recycle_rx_pool_skb(card, &vc->rcv.rx_pool);
29112911
}
2912+
kfree(vc);
29122913
}
29132914
}
29142915
}
@@ -2952,6 +2953,15 @@ open_card_ubr0(struct idt77252_dev *card)
29522953
return 0;
29532954
}
29542955

2956+
static void
2957+
close_card_ubr0(struct idt77252_dev *card)
2958+
{
2959+
struct vc_map *vc = card->vcs[0];
2960+
2961+
free_scq(card, vc->scq);
2962+
kfree(vc);
2963+
}
2964+
29552965
static int
29562966
idt77252_dev_open(struct idt77252_dev *card)
29572967
{
@@ -3001,6 +3011,7 @@ static void idt77252_dev_close(struct atm_dev *dev)
30013011
struct idt77252_dev *card = dev->dev_data;
30023012
u32 conf;
30033013

3014+
close_card_ubr0(card);
30043015
close_card_oam(card);
30053016

30063017
conf = SAR_CFG_RXPTH | /* enable receive path */

0 commit comments

Comments
 (0)