Skip to content

Commit 81e3af0

Browse files
Li Zetaocodewalkerster
authored andcommitted
net: farsync: Fix kmemleak when rmmods farsync
[ Upstream commit 2f623aa ] There are two memory leaks reported by kmemleak: unreferenced object 0xffff888114b20200 (size 128): comm "modprobe", pid 4846, jiffies 4295146524 (age 401.345s) hex dump (first 32 bytes): e0 62 57 09 81 88 ff ff e0 62 57 09 81 88 ff ff .bW......bW..... 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<ffffffff815bcd82>] kmalloc_trace+0x22/0x60 [<ffffffff83d35c78>] __hw_addr_add_ex+0x198/0x6c0 [<ffffffff83d3989d>] dev_addr_init+0x13d/0x230 [<ffffffff83d1063d>] alloc_netdev_mqs+0x10d/0xe50 [<ffffffff82b4a06e>] alloc_hdlcdev+0x2e/0x80 [<ffffffffa016a741>] fst_add_one+0x601/0x10e0 [farsync] ... unreferenced object 0xffff88810b85b000 (size 1024): comm "modprobe", pid 4846, jiffies 4295146523 (age 401.346s) hex dump (first 32 bytes): 00 00 b0 02 00 c9 ff ff 00 70 0a 00 00 c9 ff ff .........p...... 00 00 00 f2 00 00 00 f3 0a 00 00 00 02 00 00 00 ................ backtrace: [<ffffffff815bcd82>] kmalloc_trace+0x22/0x60 [<ffffffffa016a294>] fst_add_one+0x154/0x10e0 [farsync] [<ffffffff82060e83>] local_pci_probe+0xd3/0x170 ... The root cause is traced to the netdev and fst_card_info are not freed when removes one fst in fst_remove_one(), which may trigger oom if repeated insmod and rmmod module. Fix it by adding free_netdev() and kfree() in fst_remove_one(), just as the operations on the error handling path in fst_add_one(). Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Li Zetao <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 5346af6 commit 81e3af0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/wan/farsync.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,6 +2620,7 @@ fst_remove_one(struct pci_dev *pdev)
26202620
for (i = 0; i < card->nports; i++) {
26212621
struct net_device *dev = port_to_dev(&card->ports[i]);
26222622
unregister_hdlc_device(dev);
2623+
free_netdev(dev);
26232624
}
26242625

26252626
fst_disable_intr(card);
@@ -2640,6 +2641,7 @@ fst_remove_one(struct pci_dev *pdev)
26402641
card->tx_dma_handle_card);
26412642
}
26422643
fst_card_array[card->card_no] = NULL;
2644+
kfree(card);
26432645
}
26442646

26452647
static struct pci_driver fst_driver = {

0 commit comments

Comments
 (0)