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 33621A0547; Wed, 21 Apr 2021 16:17:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AEABB41AC8; Wed, 21 Apr 2021 16:17:50 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 290A7410F9; Wed, 21 Apr 2021 16:17:47 +0200 (CEST) IronPort-SDR: GebcSEQZGJvm/kggbbBq3JLyjyzgWg/X3B84331GmUYBZ+zY5MG/36wG1NdJRCKQHyPucvrrFi POhihZ1nBBUQ== X-IronPort-AV: E=McAfee;i="6200,9189,9961"; a="175811999" X-IronPort-AV: E=Sophos;i="5.82,240,1613462400"; d="scan'208";a="175811999" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2021 07:17:47 -0700 IronPort-SDR: w5VcqsCWlUiZOzhnogGJsy5CpEvKPBEbyDZ4iD7N4M4mRT7mwrCRJU62nECEA8w6MEUA9BsEwq Rl4A0lVfjayA== X-IronPort-AV: E=Sophos;i="5.82,240,1613462400"; d="scan'208";a="455358076" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.206.218]) ([10.213.206.218]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2021 07:17:44 -0700 To: Andrew Rybchenko , Thomas Monjalon , Gaetan Rivet , Stephen Hemminger , Qi Zhang , Ali Alnubani , Yuanhan Liu , Matan Azrad , Konstantin Ananyev , Zhiyong Yang , Adrien Mazarguil Cc: dev@dpdk.org, "Min Hu (Connor)" , stable@dpdk.org, Kevin Traynor References: <1618645179-11582-1-git-send-email-humin29@huawei.com> <20210421023700.1640488-1-ferruh.yigit@intel.com> <7b5f899e-aa34-ac36-ace3-7b2830257ff4@oktetlabs.ru> From: Ferruh Yigit X-User: ferruhy Message-ID: Date: Wed, 21 Apr 2021 15:17:40 +0100 MIME-Version: 1.0 In-Reply-To: <7b5f899e-aa34-ac36-ace3-7b2830257ff4@oktetlabs.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v9] ethdev: add sanity checks in control APIs 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 Sender: "dev" On 4/21/2021 12:28 PM, Andrew Rybchenko wrote: > On 4/21/21 5:36 AM, Ferruh Yigit wrote: >> From: "Min Hu (Connor)" >> >> This patch adds more sanity checks in control path APIs. >> >> Fixes: 214ed1acd125 ("ethdev: add iterator to match devargs input") >> Fixes: 3d98f921fbe9 ("ethdev: unify prefix for static functions and variables") >> Fixes: 0366137722a0 ("ethdev: check for invalid device name") >> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") >> Fixes: 5b7ba31148a8 ("ethdev: add port ownership") >> Fixes: f8244c6399d9 ("ethdev: increase port id range") >> Cc: stable@dpdk.org >> >> Signed-off-by: Min Hu (Connor) >> Signed-off-by: Ferruh Yigit >> Reviewed-by: Andrew Rybchenko >> Acked-by: Kevin Traynor <...> >> @@ -3323,6 +3457,21 @@ rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask, >> >> RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); >> dev = &rte_eth_devices[port_id]; >> + >> + if (ptypes == NULL) { >> + RTE_ETHDEV_LOG(ERR, >> + "Cannot get ethdev port %u supported packet types to NULL\n", >> + port_id); >> + return -EINVAL; >> + } >> + >> + if (num == 0) { >> + RTE_ETHDEV_LOG(ERR, >> + "Cannot get ethdev port %u supported packet types to array with zero size\n", >> + port_id); >> + return -EINVAL; >> + } >> + > > The error condition is "ptypes == NULL && num > 0". > Otherwise, if num == 0 (regardless ptypes) it is just > a call to get size of required buffer. Same as below. > >> RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_supported_ptypes_get, 0); >> all_ptypes = (*dev->dev_ops->dev_supported_ptypes_get)(dev); >> > Ack. Thanks for catching these issues.