From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D800A4414E; Tue, 4 Jun 2024 10:49:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 099A443560; Tue, 4 Jun 2024 10:48:50 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by mails.dpdk.org (Postfix) with ESMTP id BDCDB4355D for ; Tue, 4 Jun 2024 10:48:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717490928; x=1749026928; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7dnIseQgIXgimXPpCDr5fnXymXqv8SX7maygOcS5F5s=; b=AKMIe1sUw+mC9CIKq3lD42wNIA9QOMW2OeaFAAJJJti3xh/O0pygJqIl 8RDrLm8XHhcRlO7dFgvRuCpmYpjQVL9LFupBO61lRv7kX2UuDGCF7lo8/ y9G0jMHg1kFPtnZBtPmX5qVjtCyV/4/1MsmnPL85onB9CFFkxesrGmMAx nnYgKsqrR9L798YZZfU/1cG4cZYfkVCSsUi4vLAFMs1ayn1g3ZgVWIEWR 7DjIafaPq5MZ72duG1HnTWvAX9+6FfAjNRl9xRTMFimdSrO1Bd5Gfelnm cX/evG7+B5I7V7pkEeuDQGprELGgDKxu2K7oMlRJW+WcJR4CI2imug1qb A==; X-CSE-ConnectionGUID: h6dQBc5uTiiTJq9Ltm22eg== X-CSE-MsgGUID: LhIvz/M1RXC1aUANXa1O6Q== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="13971696" X-IronPort-AV: E=Sophos;i="6.08,213,1712646000"; d="scan'208";a="13971696" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2024 01:48:48 -0700 X-CSE-ConnectionGUID: yjfFYbywRMOn3grPNVAOcw== X-CSE-MsgGUID: NIEjHwYxT4ydqJcj/by9aQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,213,1712646000"; d="scan'208";a="42268644" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by orviesa004.jf.intel.com with ESMTP; 04 Jun 2024 01:48:46 -0700 From: Soumyadeep Hore To: bruce.richardson@intel.com, anatoly.burakov@intel.com Cc: dev@dpdk.org Subject: [PATCH v2 05/21] common/idpf: avoid defensive programming Date: Tue, 4 Jun 2024 08:05:55 +0000 Message-ID: <20240604080611.2197835-6-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240604080611.2197835-1-soumyadeep.hore@intel.com> References: <20240528072839.867100-1-soumyadeep.hore@intel.com> <20240604080611.2197835-1-soumyadeep.hore@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Based on the upstream feedback, driver should not use any defensive programming strategy by checking for NULL pointers and other conditional checks unnecessarily in the code flow to fall back, instead fail and fix the bug in a proper way. Some of the checks are identified and removed/wrapped in this patch: - As the control queue is freed and deleted from the list after the idpf_ctlq_shutdown call, there is no need to have the ring_size check in idpf_ctlq_shutdown. - From the upstream perspective shared code is part of the Linux driver and it doesn't make sense to add zero 'len' and 'buf_size' check in idpf_ctlq_add as to start with, driver provides valid sizes, if not it is a bug. - Remove cq NULL and zero ring_size check wherever possible as the IDPF driver code flow does not pass any NULL cq pointer to the control queue callbacks. If it passes then it is a bug and should be fixed rather than checking for NULL pointer and falling back which is not the right way. Signed-off-by: Soumyadeep Hore --- drivers/common/idpf/base/idpf_controlq.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/common/idpf/base/idpf_controlq.c b/drivers/common/idpf/base/idpf_controlq.c index bada75abfc..b5ba9c3bd0 100644 --- a/drivers/common/idpf/base/idpf_controlq.c +++ b/drivers/common/idpf/base/idpf_controlq.c @@ -98,9 +98,6 @@ static void idpf_ctlq_shutdown(struct idpf_hw *hw, struct idpf_ctlq_info *cq) { idpf_acquire_lock(&cq->cq_lock); - if (!cq->ring_size) - goto shutdown_sq_out; - #ifdef SIMICS_BUILD wr32(hw, cq->reg.head, 0); wr32(hw, cq->reg.tail, 0); @@ -115,7 +112,6 @@ static void idpf_ctlq_shutdown(struct idpf_hw *hw, struct idpf_ctlq_info *cq) /* Set ring_size to 0 to indicate uninitialized queue */ cq->ring_size = 0; -shutdown_sq_out: idpf_release_lock(&cq->cq_lock); idpf_destroy_lock(&cq->cq_lock); } -- 2.43.0