bus/pci: fix return value check of device FD
PATCH 1/1 bus/pci: fix return value check of device FD
Fixing return value check of rte_intr_dev_fd_get() to make sure negative device FD will not be used later.
Coverity issue: 385380, 385373
Fixes 095cf6e68b28 ("bus/pci: introduce MMIO read/write")
Fixes 4b741542ecde ("bus/pci: avoid depending on private kernel value")
Signed-off-by Chenbo Xia <[email protected]>
--- drivers/bus/pci/linux/pci_vfio.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/bus/pci/linux/pci_vfio.c +8 -0
@@ -71,6 +71,8 @@ pci_vfio_read_config(const struct rte_pci_device *dev,int fd; fd =rte_intr_dev_fd_get (dev->intr_handle); +if (fd <0 ) +return -1 ;if (pci_vfio_get_region (dev,VFIO_PCI_CONFIG_REGION_INDEX , &size, &offset) !=0 )
@@ -90,6 +92,8 @@ pci_vfio_write_config(const struct rte_pci_device *dev,int fd; fd =rte_intr_dev_fd_get (dev->intr_handle); +if (fd <0 ) +return -1 ;if (pci_vfio_get_region (dev,VFIO_PCI_CONFIG_REGION_INDEX , &size, &offset) !=0 )
@@ -1369,6 +1373,8 @@ pci_vfio_mmio_read(const struct rte_pci_device *dev, int bar,int fd; fd =rte_intr_dev_fd_get (dev->intr_handle); +if (fd <0 ) +return -1 ;if (pci_vfio_get_region (dev, bar, &size, &offset) !=0 )return -1 ;
@@ -1387,6 +1393,8 @@ pci_vfio_mmio_write(const struct rte_pci_device *dev, int bar,int fd; fd =rte_intr_dev_fd_get (dev->intr_handle); +if (fd <0 ) +return -1 ;if (pci_vfio_get_region (dev, bar, &size, &offset) !=0 )return -1 ;
Signature · 1 line
2.17.1
Quoted 9 lines · Chenbo Xia
Fixing return value check of
rte_intr_dev_fd_get()to make sure negative device FD will not be used later.Coverity issue: 385380, 385373
Fixes 095cf6e68b28 ("bus/pci: introduce MMIO read/write")Fixes 4b741542ecde ("bus/pci: avoid depending on private kernel value")Signed-off-by Chenbo Xia <[email protected]>---
Acked-by Anatoly Burakov <[email protected]>
Signature · 2 lines
Thanks, Anatoly
Thomas Monjalon
Applied12/06/2023 11:47, Burakov, Anatoly:
Quoted 12 lines · Chenbo Xia
Quoted 9 lines
Fixing return value check of
rte_intr_dev_fd_get()to make sure negative device FD will not be used later.Coverity issue: 385380, 385373
Fixes 095cf6e68b28 ("bus/pci: introduce MMIO read/write")Fixes 4b741542ecde ("bus/pci: avoid depending on private kernel value")Signed-off-by Chenbo Xia <[email protected]>---
Acked-by Anatoly Burakov <[email protected]>
Applied, thanks.