• Ido Schimmel's avatar
    mlxsw: spectrum_nve: Fix memory leak upon driver reload · 5edb7e8b
    Ido Schimmel authored
    The pointer was NULLed before freeing the memory, resulting in a memory
    leak. Trace from kmemleak:
    
    unreferenced object 0xffff88820ae36528 (size 512):
      comm "devlink", pid 5374, jiffies 4295354033 (age 10829.296s)
      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:
        [<00000000a43f5195>] kmem_cache_alloc_trace+0x1be/0x330
        [<00000000312f8140>] mlxsw_sp_nve_init+0xcb/0x1ae0
        [<0000000009201d22>] mlxsw_sp_init+0x1382/0x2690
        [<000000007227d877>] mlxsw_sp1_init+0x1b5/0x260
        [<000000004a16feec>] __mlxsw_core_bus_device_register+0x776/0x1360
        [<0000000070ab954c>] mlxsw_devlink_core_bus_device_reload+0x129/0x220
        [<00000000432313d5>] devlink_nl_cmd_reload+0x119/0x1e0
        [<000000003821a06b>] genl_family_rcv_msg+0x813/0x1150
        [<00000000d54d04c0>] genl_rcv_msg+0xd1/0x180
        [<0000000040543d12>] netlink_rcv_skb+0x152/0x3c0
        [<00000000efc4eae8>] genl_rcv+0x2d/0x40
        [<00000000ea645603>] netlink_unicast+0x52f/0x740
        [<00000000641fca1a>] netlink_sendmsg+0x9c7/0xf50
        [<00000000fed4a4b8>] sock_sendmsg+0xbe/0x120
        [<00000000d85795a9>] __sys_sendto+0x397/0x620
        [<00000000c5f84622>] __x64_sys_sendto+0xe6/0x1a0
    
    Fixes: 6e6030bd ("mlxsw: spectrum_nve: Implement common NVE core")
    Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
    Reviewed-by: default avatarPetr Machata <petrm@mellanox.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    5edb7e8b
spectrum_nve.c 25.8 KB