linux/drivers/net/ethernet/sfc
Taehee Yoo 1fa89ffbc0 net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe()
In the NIC ->probe() callback, ->mtd_probe() callback is called.
If NIC has 2 ports, ->probe() is called twice and ->mtd_probe() too.
In the ->mtd_probe(), which is efx_ef10_mtd_probe() it allocates and
initializes mtd partiion.
But mtd partition for sfc is shared data.
So that allocated mtd partition data from last called
efx_ef10_mtd_probe() will not be used.
Therefore it must be freed.
But it doesn't free a not used mtd partition data in efx_ef10_mtd_probe().

kmemleak reports:
unreferenced object 0xffff88811ddb0000 (size 63168):
  comm "systemd-udevd", pid 265, jiffies 4294681048 (age 348.586s)
  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:
    [<ffffffffa3767749>] kmalloc_order_trace+0x19/0x120
    [<ffffffffa3873f0e>] __kmalloc+0x20e/0x250
    [<ffffffffc041389f>] efx_ef10_mtd_probe+0x11f/0x270 [sfc]
    [<ffffffffc0484c8a>] efx_pci_probe.cold.17+0x3df/0x53d [sfc]
    [<ffffffffa414192c>] local_pci_probe+0xdc/0x170
    [<ffffffffa4145df5>] pci_device_probe+0x235/0x680
    [<ffffffffa443dd52>] really_probe+0x1c2/0x8f0
    [<ffffffffa443e72b>] __driver_probe_device+0x2ab/0x460
    [<ffffffffa443e92a>] driver_probe_device+0x4a/0x120
    [<ffffffffa443f2ae>] __driver_attach+0x16e/0x320
    [<ffffffffa4437a90>] bus_for_each_dev+0x110/0x190
    [<ffffffffa443b75e>] bus_add_driver+0x39e/0x560
    [<ffffffffa4440b1e>] driver_register+0x18e/0x310
    [<ffffffffc02e2055>] 0xffffffffc02e2055
    [<ffffffffa3001af3>] do_one_initcall+0xc3/0x450
    [<ffffffffa33ca574>] do_init_module+0x1b4/0x700

Acked-by: Martin Habets <habetsm.xilinx@gmail.com>
Fixes: 8127d661e7 ("sfc: Add support for Solarflare SFC9100 family")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Link: https://lore.kernel.org/r/20220512054709.12513-1-ap420073@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-05-12 10:01:36 -07:00
..
falcon Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-01-05 14:36:10 -08:00
bitfield.h
ef10_regs.h
ef10_sriov.c ethernet: constify references to netdev->dev_addr in drivers 2021-10-14 09:22:11 -07:00
ef10_sriov.h ethernet: constify references to netdev->dev_addr in drivers 2021-10-14 09:22:11 -07:00
ef10.c net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe() 2022-05-12 10:01:36 -07:00
ef100_ethtool.c ethtool: extend ringparam setting/getting API with rx_buf_len 2021-11-22 12:31:49 +00:00
ef100_ethtool.h
ef100_netdev.c
ef100_netdev.h
ef100_nic.c sfc: The size of the RX recycle ring should be more flexible 2022-02-01 20:34:59 -08:00
ef100_nic.h
ef100_regs.h
ef100_rx.c
ef100_rx.h
ef100_tx.c
ef100_tx.h
ef100.c
ef100.h
efx_channels.c net: sfc: fix memory leak due to ptp channel 2022-05-09 10:01:48 +01:00
efx_channels.h
efx_common.c net: Don't include filter.h from net/sock.h 2021-12-29 08:48:14 -08:00
efx_common.h
efx.c net: Don't include filter.h from net/sock.h 2021-12-29 08:48:14 -08:00
efx.h
enum.h
ethtool_common.c sfc: Fix reading non-legacy supported link modes 2021-10-18 14:28:02 +01:00
ethtool_common.h
ethtool.c ethtool: extend ringparam setting/getting API with rx_buf_len 2021-11-22 12:31:49 +00:00
farch_regs.h
farch.c
filter.h
io.h
Kconfig ethernet: fix PTP_1588_CLOCK dependencies 2021-08-13 17:49:05 -07:00
Makefile
mcdi_filters.c
mcdi_filters.h
mcdi_functions.c
mcdi_functions.h
mcdi_mon.c
mcdi_pcol.h
mcdi_port_common.c ethernet/sfc: remove redundant rc variable 2022-01-04 12:41:41 +00:00
mcdi_port_common.h
mcdi_port.c
mcdi_port.h
mcdi.c sfc: extend the locking on mcdi->seqno 2022-03-03 14:11:58 +00:00
mcdi.h
mtd.c
net_driver.h sfc: The size of the RX recycle ring should be more flexible 2022-02-01 20:34:59 -08:00
nic_common.h sfc: The size of the RX recycle ring should be more flexible 2022-02-01 20:34:59 -08:00
nic.c
nic.h
ptp.c net: sfc: fix memory leak due to ptp channel 2022-05-09 10:01:48 +01:00
ptp.h net: sfc: fix memory leak due to ptp channel 2022-05-09 10:01:48 +01:00
rx_common.c sfc: Do not free an empty page_ring 2022-04-04 12:53:52 +01:00
rx_common.h sfc: The size of the RX recycle ring should be more flexible 2022-02-01 20:34:59 -08:00
rx.c bpf: Let bpf_warn_invalid_xdp_action() report more info 2021-12-13 22:28:27 +01:00
selftest.c
selftest.h
siena_sriov.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-10-22 11:41:16 +01:00
siena_sriov.h ethernet: constify references to netdev->dev_addr in drivers 2021-10-14 09:22:11 -07:00
siena.c sfc: The size of the RX recycle ring should be more flexible 2022-02-01 20:34:59 -08:00
sriov.c
sriov.h
tx_common.c net: sfc: fix using uninitialized xdp tx_queue 2022-04-06 13:50:17 +01:00
tx_common.h
tx_tso.c
tx.c net: sfc: fix using uninitialized xdp tx_queue 2022-04-06 13:50:17 +01:00
tx.h
vfdi.h
workarounds.h