]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ice: Graceful error handling in HW table calloc failure
authorSurabhi Boob <surabhi.boob@intel.com>
Thu, 30 Jul 2020 00:19:18 +0000 (17:19 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Aug 2020 06:24:05 +0000 (08:24 +0200)
[ Upstream commit bcc46cb8a077c6189b44f1555b8659837f748eb2 ]

In the ice_init_hw_tbls, if the devm_kcalloc for es->written fails, catch
that error and bail out gracefully, instead of continuing with a NULL
pointer.

Fixes: 32d63fa1e9f3 ("ice: Initialize DDP package structures")
Signed-off-by: Surabhi Boob <surabhi.boob@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/ice/ice_flex_pipe.c

index d60e31f65749f40a10a61dc91ca816cca59163ea..a9a89bdb6036a25bc558648312a7250140aa3fcc 100644 (file)
@@ -2521,10 +2521,12 @@ enum ice_status ice_init_hw_tbls(struct ice_hw *hw)
                es->ref_count = devm_kcalloc(ice_hw_to_dev(hw), es->count,
                                             sizeof(*es->ref_count),
                                             GFP_KERNEL);
+               if (!es->ref_count)
+                       goto err;
 
                es->written = devm_kcalloc(ice_hw_to_dev(hw), es->count,
                                           sizeof(*es->written), GFP_KERNEL);
-               if (!es->ref_count)
+               if (!es->written)
                        goto err;
        }
        return 0;