• Przemek Kitszel's avatar
    ice: fix memleak in ice_init_tx_topology() · c188afdc
    Przemek Kitszel authored
    Fix leak of the FW blob (DDP pkg).
    
    Make ice_cfg_tx_topo() const-correct, so ice_init_tx_topology() can avoid
    copying whole FW blob. Copy just the topology section, and only when
    needed. Reuse the buffer allocated for the read of the current topology.
    
    This was found by kmemleak, with the following trace for each PF:
        [<ffffffff8761044d>] kmemdup_noprof+0x1d/0x50
        [<ffffffffc0a0a480>] ice_init_ddp_config+0x100/0x220 [ice]
        [<ffffffffc0a0da7f>] ice_init_dev+0x6f/0x200 [ice]
        [<ffffffffc0a0dc49>] ice_init+0x29/0x560 [ice]
        [<ffffffffc0a10c1d>] ice_probe+0x21d/0x310 [ice]
    
    Constify ice_cfg_tx_topo() @buf parameter.
    This cascades further down to few more functions.
    
    Fixes: cc5776fe ("ice: Enable switching default Tx scheduler topology")
    CC: Larysa Zaremba <larysa.zaremba@intel.com>
    CC: Jacob Keller <jacob.e.keller@intel.com>
    CC: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>
    CC: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
    Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
    Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
    Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
    Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
    c188afdc
ice_ddp.c 67.9 KB