]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ice: Fix resource leak on early exit from function
authorEric Joyner <eric.joyner@intel.com>
Fri, 8 May 2020 00:41:07 +0000 (17:41 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:32:46 +0000 (09:32 +0200)
[ Upstream commit 857a4f0e9f4956fffc0cedcaa2ba187a2e987153 ]

Memory allocated in the ice_add_prof_id_vsig() function wasn't being
properly freed if an error occurred inside the for-loop in the function.

In particular, 'p' wasn't being freed if an error occurred before it was
added to the resource list at the end of the for-loop.

Signed-off-by: Eric Joyner <eric.joyner@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/ice/ice_flex_pipe.c

index e7a2671222d2c80e8db9293ec465b1bf4fd9fdbc..abfec38bb48318851c6aa149dad443d40ada2f09 100644 (file)
@@ -3705,8 +3705,10 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
                                              t->tcam[i].prof_id,
                                              t->tcam[i].ptg, vsig, 0, 0,
                                              vl_msk, dc_msk, nm_msk);
-               if (status)
+               if (status) {
+                       devm_kfree(ice_hw_to_dev(hw), p);
                        goto err_ice_add_prof_id_vsig;
+               }
 
                /* log change */
                list_add(&p->list_entry, chg);