Fix leak of the FW blob, by not copying it.
ice_cfg_tx_topo() is not changing the passed buffer, but constification
of it is not a -net material, constification patch is mentioned by Link.

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]

Link: 
https://lore.kernel.org/intel-wired-lan/20240904093135.8795-2-przemyslaw.kits...@intel.com
Fixes: cc5776fe1832 ("ice: Enable switching default Tx scheduler topology")
Reviewed-by: Larysa Zaremba <larysa.zare...@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kits...@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_main.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index 6f97ed471fe9..71f592dda156 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -4535,16 +4535,10 @@ ice_init_tx_topology(struct ice_hw *hw, const struct 
firmware *firmware)
        u8 num_tx_sched_layers = hw->num_tx_sched_layers;
        struct ice_pf *pf = hw->back;
        struct device *dev;
-       u8 *buf_copy;
        int err;
 
        dev = ice_pf_to_dev(pf);
-       /* ice_cfg_tx_topo buf argument is not a constant,
-        * so we have to make a copy
-        */
-       buf_copy = kmemdup(firmware->data, firmware->size, GFP_KERNEL);
-
-       err = ice_cfg_tx_topo(hw, buf_copy, firmware->size);
+       err = ice_cfg_tx_topo(hw, (void *)firmware->data, firmware->size);
        if (!err) {
                if (hw->num_tx_sched_layers > num_tx_sched_layers)
                        dev_info(dev, "Tx scheduling layers switching feature 
disabled\n");

base-commit: 4186c8d9e6af57bab0687b299df10ebd47534a0a
-- 
2.46.0

Reply via email to