ice: fix memory leak in ice_vsi_setup
authorJacob Keller <jacob.e.keller@intel.com>
Wed, 2 Sep 2020 15:53:47 +0000 (08:53 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 25 Sep 2020 14:39:24 +0000 (07:39 -0700)
commitf6a07271bb1535d9549380461437cc48d9e19958
tree197e3eaa91940bc7645ba0ac954c6f2dee298655
parent135f4b9e9340dadb78e9737bb4eb9817b9c89dac
ice: fix memory leak in ice_vsi_setup

During ice_vsi_setup, if ice_cfg_vsi_lan fails, it does not properly
release memory associated with the VSI rings. If we had used devres
allocations for the rings, this would be ok. However, we use kzalloc and
kfree_rcu for these ring structures.

Using the correct label to cleanup the rings during ice_vsi_setup
highlights an issue in the ice_vsi_clear_rings function: it can leave
behind stale ring pointers in the q_vectors structure.

When releasing rings, we must also ensure that no q_vector associated
with the VSI will point to this ring again. To resolve this, loop over
all q_vectors and release their ring mapping. Because we are about to
free all rings, no q_vector should remain pointing to any of the rings
in this VSI.

Fixes: 5513b920a4f7 ("ice: Update Tx scheduler tree for VSI multi-Tx queue support")
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