DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] bus/pci: fix return value check of device FD
@ 2023-06-12  5:11 Chenbo Xia
  2023-06-12  9:47 ` Burakov, Anatoly
  0 siblings, 1 reply; 3+ messages in thread
From: Chenbo Xia @ 2023-06-12  5:11 UTC (permalink / raw)
  To: dev; +Cc: anatoly.burakov

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 <chenbo.xia@intel.com>
---
 drivers/bus/pci/linux/pci_vfio.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index ef8f9f4197..e634de8322 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -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;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bus/pci: fix return value check of device FD
  2023-06-12  5:11 [PATCH] bus/pci: fix return value check of device FD Chenbo Xia
@ 2023-06-12  9:47 ` Burakov, Anatoly
  2023-06-12 16:36   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Burakov, Anatoly @ 2023-06-12  9:47 UTC (permalink / raw)
  To: Chenbo Xia, dev

On 6/12/2023 6:11 AM, Chenbo Xia wrote:
> 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 <chenbo.xia@intel.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bus/pci: fix return value check of device FD
  2023-06-12  9:47 ` Burakov, Anatoly
@ 2023-06-12 16:36   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2023-06-12 16:36 UTC (permalink / raw)
  To: Chenbo Xia; +Cc: dev, Burakov, Anatoly

12/06/2023 11:47, Burakov, Anatoly:
> On 6/12/2023 6:11 AM, Chenbo Xia wrote:
> > 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 <chenbo.xia@intel.com>
> > ---
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-12 16:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12  5:11 [PATCH] bus/pci: fix return value check of device FD Chenbo Xia
2023-06-12  9:47 ` Burakov, Anatoly
2023-06-12 16:36   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).