From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 776261B43F; Fri, 19 Apr 2019 03:19:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Apr 2019 18:19:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,368,1549958400"; d="scan'208";a="317174224" Received: from xiachenbo.sh.intel.com (HELO NPG_DPDK_VIRTIO_XIACHENBO_OD_.sh.intel.com) ([10.67.119.199]) by orsmga005.jf.intel.com with ESMTP; 18 Apr 2019 18:19:00 -0700 From: Chenbo Xia To: dev@dpdk.org Cc: jianjay.zhou@huawei.com, stable@dpdk.org Date: Fri, 19 Apr 2019 00:58:34 +0000 Message-Id: <20190419005834.34023-1-chenbo.xia@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1] crypto/virtio: fix return value check 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: , X-List-Received-Date: Fri, 19 Apr 2019 01:19:03 -0000 Fix unchecked return value issue for rte_pci_read_config. Coverity issue: 302861 Fixes: 25500d4b8076 ("crypto/virtio: support device init") Cc: stable@dpdk.org Signed-off-by: Chenbo Xia --- drivers/crypto/virtio/virtio_pci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/virtio/virtio_pci.c b/drivers/crypto/virtio/virtio_pci.c index 0c0c64471..8137b3c5a 100644 --- a/drivers/crypto/virtio/virtio_pci.c +++ b/drivers/crypto/virtio/virtio_pci.c @@ -397,9 +397,13 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_crypto_hw *hw) hw->common_cfg = get_cfg_addr(dev, &cap); break; case VIRTIO_PCI_CAP_NOTIFY_CFG: - rte_pci_read_config(dev, &hw->notify_off_multiplier, + ret = rte_pci_read_config(dev, &hw->notify_off_multiplier, 4, pos + sizeof(cap)); - hw->notify_base = get_cfg_addr(dev, &cap); + if (ret != 4) + VIRTIO_CRYPTO_INIT_LOG_ERR( + "failed to read notify_off_multiplier: ret %d", ret); + else + hw->notify_base = get_cfg_addr(dev, &cap); break; case VIRTIO_PCI_CAP_DEVICE_CFG: hw->dev_cfg = get_cfg_addr(dev, &cap); -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 244F7A00E6 for ; Fri, 19 Apr 2019 03:19:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BDAE41BB09; Fri, 19 Apr 2019 03:19:04 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 776261B43F; Fri, 19 Apr 2019 03:19:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Apr 2019 18:19:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,368,1549958400"; d="scan'208";a="317174224" Received: from xiachenbo.sh.intel.com (HELO NPG_DPDK_VIRTIO_XIACHENBO_OD_.sh.intel.com) ([10.67.119.199]) by orsmga005.jf.intel.com with ESMTP; 18 Apr 2019 18:19:00 -0700 From: Chenbo Xia To: dev@dpdk.org Cc: jianjay.zhou@huawei.com, stable@dpdk.org Date: Fri, 19 Apr 2019 00:58:34 +0000 Message-Id: <20190419005834.34023-1-chenbo.xia@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1] crypto/virtio: fix return value check 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190419005834.ZWJyVhrpVttzygpALGIfEOQaS_-37hrnDi_7Z46vUeU@z> Fix unchecked return value issue for rte_pci_read_config. Coverity issue: 302861 Fixes: 25500d4b8076 ("crypto/virtio: support device init") Cc: stable@dpdk.org Signed-off-by: Chenbo Xia --- drivers/crypto/virtio/virtio_pci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/virtio/virtio_pci.c b/drivers/crypto/virtio/virtio_pci.c index 0c0c64471..8137b3c5a 100644 --- a/drivers/crypto/virtio/virtio_pci.c +++ b/drivers/crypto/virtio/virtio_pci.c @@ -397,9 +397,13 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_crypto_hw *hw) hw->common_cfg = get_cfg_addr(dev, &cap); break; case VIRTIO_PCI_CAP_NOTIFY_CFG: - rte_pci_read_config(dev, &hw->notify_off_multiplier, + ret = rte_pci_read_config(dev, &hw->notify_off_multiplier, 4, pos + sizeof(cap)); - hw->notify_base = get_cfg_addr(dev, &cap); + if (ret != 4) + VIRTIO_CRYPTO_INIT_LOG_ERR( + "failed to read notify_off_multiplier: ret %d", ret); + else + hw->notify_base = get_cfg_addr(dev, &cap); break; case VIRTIO_PCI_CAP_DEVICE_CFG: hw->dev_cfg = get_cfg_addr(dev, &cap); -- 2.17.1