[dpdk-dev,v2] vfio: check ioctl return value

Message ID 1509031189-22601-1-git-send-email-jpf@zurich.ibm.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jonas Pfefferle1 Oct. 26, 2017, 3:19 p.m. UTC
  Check return value of device reset ioctl

Fixes: 33604c31354a ("vfio: refactor PCI BAR mapping")
Coverity issue: 195003

Signed-off-by: Jonas Pfefferle <jpf@zurich.ibm.com>
---
v2:
* fix whitespace/tab issue

 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Anatoly Burakov Oct. 26, 2017, 3:23 p.m. UTC | #1
On 26-Oct-17 4:19 PM, Jonas Pfefferle wrote:
> Check return value of device reset ioctl
> 
> Fixes: 33604c31354a ("vfio: refactor PCI BAR mapping")
> Coverity issue: 195003
> 
> Signed-off-by: Jonas Pfefferle <jpf@zurich.ibm.com>
> ---
> v2:
> * fix whitespace/tab issue
> 
>   lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> index d407c87..f11f683 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> @@ -333,7 +333,11 @@ pci_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
>   	}
>   
>   	/* Reset the device */
> -	ioctl(vfio_dev_fd, VFIO_DEVICE_RESET);
> +	if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET)) {
> +		RTE_LOG(ERR, EAL, "Unable to reset device! Error: %d (%s)\n",
> +				errno, strerror(errno));
> +		return -1;
> +	}
>   
>   	return 0;
>   }
> 

Looks fine to me, so

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
Thomas Monjalon Oct. 26, 2017, 9:52 p.m. UTC | #2
26/10/2017 17:23, Burakov, Anatoly:
> On 26-Oct-17 4:19 PM, Jonas Pfefferle wrote:
> > Check return value of device reset ioctl
> > 
> > Fixes: 33604c31354a ("vfio: refactor PCI BAR mapping")
> > Coverity issue: 195003
> > 
> > Signed-off-by: Jonas Pfefferle <jpf@zurich.ibm.com>
> 
> Looks fine to me, so
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index d407c87..f11f683 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -333,7 +333,11 @@  pci_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
 	}
 
 	/* Reset the device */
-	ioctl(vfio_dev_fd, VFIO_DEVICE_RESET);
+	if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET)) {
+		RTE_LOG(ERR, EAL, "Unable to reset device! Error: %d (%s)\n",
+				errno, strerror(errno));
+		return -1;
+	}
 
 	return 0;
 }