From patchwork Mon Sep 7 11:27:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 76687 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B9796A04B5; Mon, 7 Sep 2020 13:24:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 03CCB1C0CD; Mon, 7 Sep 2020 13:24:37 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id B277D29AC for ; Mon, 7 Sep 2020 13:24:33 +0200 (CEST) IronPort-SDR: FTrstmEfqZ1gEBc+IcBXHwY64KfJBj5401GyTYWBAYgqr4R/L8qaO1rOj6tiiWpCOMZ7t0TT+i KGRJnaa8h5yg== X-IronPort-AV: E=McAfee;i="6000,8403,9736"; a="157252575" X-IronPort-AV: E=Sophos;i="5.76,401,1592895600"; d="scan'208";a="157252575" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 04:24:32 -0700 IronPort-SDR: acqmu2mHPJRmNQ2ZNs+/6O++zGrM+1etUNh7ENIHjSgsewSrsXKJt45+odpdzjLMqc4kMxr1EZ OC3lt7f7Zs2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,401,1592895600"; d="scan'208";a="328058718" Received: from dpdk51.sh.intel.com ([10.67.111.82]) by fmsmga004.fm.intel.com with ESMTP; 07 Sep 2020 04:24:31 -0700 From: Qi Zhang To: qiming.yang@intel.com Cc: dev@dpdk.org, Qi Zhang , Surabhi Boob Date: Mon, 7 Sep 2020 19:27:47 +0800 Message-Id: <20200907112826.48493-2-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20200907112826.48493-1-qi.z.zhang@intel.com> References: <20200907112826.48493-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH 01/40] net/ice/base: handle error gracefully in HW table calloc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 999ad6be3..bf8530e89 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;