crypto/virtio: check PCI config read
authorChenbo Xia <chenbo.xia@intel.com>
Fri, 19 Apr 2019 00:58:34 +0000 (00:58 +0000)
committerAkhil Goyal <akhil.goyal@nxp.com>
Fri, 5 Jul 2019 12:52:25 +0000 (14:52 +0200)
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 <chenbo.xia@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
drivers/crypto/virtio/virtio_pci.c

index 0c0c644..8137b3c 100644 (file)
@@ -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);