]> git.baikalelectronics.ru Git - kernel.git/commit
ice: fix memory leak if register_netdev_fails
authorJacob Keller <jacob.e.keller@intel.com>
Wed, 2 Sep 2020 15:53:46 +0000 (08:53 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 25 Sep 2020 14:39:24 +0000 (07:39 -0700)
commit788c7bed21d99f2d9d57db931ca1776460916d58
tree9ea284ed2431155708a4264dce01a789cfc55361
parent4146d8d9fe330cd256d130b85ad44d6672021e1b
ice: fix memory leak if register_netdev_fails

The ice_setup_pf_sw function can cause a memory leak if register_netdev
fails, due to accidentally failing to free the VSI rings. Fix the memory
leak by using ice_vsi_release, ensuring we actually go through the full
teardown process.

This should be safe even if the netdevice is not registered because we
will have set the netdev pointer to NULL, ensuring ice_vsi_release won't
call unregister_netdev.

An alternative fix would be moving management of the PF VSI netdev into
the main VSI setup code. This is complicated and likely requires
significant refactor in how we manage VSIs

Fixes: 66de74db3055 ("ice: Add support for VSI allocation and deallocation")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_lib.c
drivers/net/ethernet/intel/ice/ice_lib.h
drivers/net/ethernet/intel/ice/ice_main.c