Patch "net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe()" has been added to the 4.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe()

to the 4.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-sfc-ef10-fix-memory-leak-in-efx_ef10_mtd_probe.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 509ec202108ce1571f0b337d4ab1d3bc15660ffa
Author: Taehee Yoo <ap420073@xxxxxxxxx>
Date:   Thu May 12 05:47:09 2022 +0000

    net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe()
    
    [ Upstream commit 1fa89ffbc04545b7582518e57f4b63e2a062870f ]
    
    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@xxxxxxxxx>
    Fixes: 8127d661e77f ("sfc: Add support for Solarflare SFC9100 family")
    Signed-off-by: Taehee Yoo <ap420073@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20220512054709.12513-1-ap420073@xxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 22bc3dc44298..aa2cef8675f4 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -5197,6 +5197,11 @@ static int efx_ef10_mtd_probe(struct efx_nic *efx)
 		n_parts++;
 	}
 
+	if (!n_parts) {
+		kfree(parts);
+		return 0;
+	}
+
 	rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts));
 fail:
 	if (rc)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux