From 8a15c69ce9abbdcc2b4593d157f16fc72783cd4a Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Wed, 26 Aug 2020 11:14:07 +0800 Subject: [PATCH] net/ice/base: handle error gracefully in HW table calloc In the ice_init_hw_tbls API, if the ice_calloc for es->written fails, catch that error and bail out gracefully, instead of continuing with a NULL pointer. Signed-off-by: Surabhi Boob Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/base/ice_flex_pipe.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c index 999ad6be3c..bf8530e89e 100644 --- a/drivers/net/ice/base/ice_flex_pipe.c +++ b/drivers/net/ice/base/ice_flex_pipe.c @@ -3908,11 +3908,19 @@ enum ice_status ice_init_hw_tbls(struct ice_hw *hw) es->ref_count = (u16 *) ice_calloc(hw, es->count, sizeof(*es->ref_count)); + if (!es->ref_count) + goto err; + es->written = (u8 *) ice_calloc(hw, es->count, sizeof(*es->written)); + + if (!es->written) + goto err; + es->mask_ena = (u32 *) ice_calloc(hw, es->count, sizeof(*es->mask_ena)); - if (!es->ref_count) + + if (!es->mask_ena) goto err; } return ICE_SUCCESS; -- 2.20.1