diff mbox series

[S51,09/13] ice: Graceful error handling in HW table calloc failure

Message ID 20200730001922.52568-9-anthony.l.nguyen@intel.com
State Accepted
Delegated to: Anthony Nguyen
Headers show
Series [S51,01/13] ice: rename misleading grst_delay variable | expand

Commit Message

Tony Nguyen July 30, 2020, 12:19 a.m. UTC
From: Surabhi Boob <surabhi.boob@intel.com>

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>
---
 drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Bowers, AndrewX July 31, 2020, 7:58 p.m. UTC | #1
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Tony Nguyen
> Sent: Wednesday, July 29, 2020 5:19 PM
> To: intel-wired-lan@lists.osuosl.org
> Subject: [Intel-wired-lan] [PATCH S51 09/13] ice: Graceful error handling in
> HW table calloc failure
> 
> From: Surabhi Boob <surabhi.boob@intel.com>
> 
> 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>
> ---
>  drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
index d59869b2c65e..d8ada9675650 100644
--- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
+++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
@@ -3152,9 +3152,13 @@  enum ice_status ice_init_hw_tbls(struct ice_hw *hw)
 					     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;