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 CB5C9A0C41; Wed, 15 Sep 2021 16:35:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B556941123; Wed, 15 Sep 2021 16:35:06 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id B69C54014F for ; Wed, 15 Sep 2021 16:35:05 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10107"; a="244704628" X-IronPort-AV: E=Sophos;i="5.85,295,1624345200"; d="scan'208";a="244704628" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2021 07:35:04 -0700 X-IronPort-AV: E=Sophos;i="5.85,295,1624345200"; d="scan'208";a="553319676" Received: from mmcgar2x-mobl.ger.corp.intel.com (HELO bricha3-MOBL.ger.corp.intel.com) ([10.252.4.169]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 15 Sep 2021 07:35:00 -0700 Date: Wed, 15 Sep 2021 15:34:57 +0100 From: Bruce Richardson To: Kevin Laatz Cc: Chengwen Feng , thomas@monjalon.net, ferruh.yigit@intel.com, jerinj@marvell.com, jerinjacobk@gmail.com, andrew.rybchenko@oktetlabs.ru, dev@dpdk.org, mb@smartsharesystems.com, nipun.gupta@nxp.com, hemant.agrawal@nxp.com, maxime.coquelin@redhat.com, honnappa.nagarahalli@arm.com, david.marchand@redhat.com, sburla@marvell.com, pkapoor@marvell.com, konstantin.ananyev@intel.com, conor.walsh@intel.com Message-ID: References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210907125649.49794-1-fengchengwen@huawei.com> <20210907125649.49794-5-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Subject: Re: [dpdk-dev] [PATCH v21 4/7] dmadev: introduce DMA device library implementation 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 Wed, Sep 15, 2021 at 02:51:55PM +0100, Kevin Laatz wrote: > On 07/09/2021 13:56, Chengwen Feng wrote: > > This patch introduce DMA device library implementation which includes > > configuration and I/O with the DMA devices. > > > > Signed-off-by: Chengwen Feng > > Acked-by: Bruce Richardson > > Acked-by: Morten Brørup > > Reviewed-by: Kevin Laatz > > Reviewed-by: Conor Walsh > > --- > > config/rte_config.h | 3 + > > lib/dmadev/meson.build | 1 + > > lib/dmadev/rte_dmadev.c | 607 +++++++++++++++++++++++++++++++++++ > > lib/dmadev/rte_dmadev.h | 118 ++++++- > > lib/dmadev/rte_dmadev_core.h | 2 + > > lib/dmadev/version.map | 1 + > > 6 files changed, 720 insertions(+), 12 deletions(-) > > create mode 100644 lib/dmadev/rte_dmadev.c > > > [snip] > > > /** > > * @warning > > @@ -941,10 +1018,27 @@ rte_dmadev_completed(uint16_t dev_id, uint16_t vchan, const uint16_t nb_cpls, > > * status array are also set. > > */ > > __rte_experimental > > -uint16_t > > +static inline uint16_t > > rte_dmadev_completed_status(uint16_t dev_id, uint16_t vchan, > > const uint16_t nb_cpls, uint16_t *last_idx, > > - enum rte_dma_status_code *status); > > + enum rte_dma_status_code *status) > > +{ > > + struct rte_dmadev *dev = &rte_dmadevices[dev_id]; > > + uint16_t idx; > > + > > +#ifdef RTE_DMADEV_DEBUG > > + if (!rte_dmadev_is_valid_dev(dev_id) || !dev->data->dev_started || > > + vchan >= dev->data->dev_conf.nb_vchans || > > + nb_cpls == 0 || status == NULL) > > + return 0; > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->completed_status, 0); > > +#endif > > + > > + if (last_idx == NULL) > > + last_idx = &idx; > > Hi Chengwen, > > An internal coverity scan on the IDXD dmadev driver patches flagged a > potential null pointer dereference when using completed_status(). > > IMO it is a false positive for the driver code since it should be checked at > the library API level, however the check is also not present in the library. > > For the v22, can you add the NULL pointer check for status here, like you > have for last_idx, please? > I think the check would have to be different than that for last_idx, since the status pointer is a pointer to an array, rather than a single value - which procludes a simple replacement in the wrapper function that the compiler can inline away if unnecessary. It's probably best to add it as a check in the debug block, with an error-return if status is NULL. /Bruce