diff mbox series

s390x/vfio-ap: report correct error

Message ID 20181016115817.14605-1-cohuck@redhat.com
State New
Headers show
Series s390x/vfio-ap: report correct error | expand

Commit Message

Cornelia Huck Oct. 16, 2018, 11:58 a.m. UTC
If ioctl(..., VFIO_DEVICE_RESET) fails, we want to report errno
instead of ret (which is always -1 on error).

Fixes Coverity issue CID 1396176.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
 hw/vfio/ap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian Borntraeger Oct. 16, 2018, 12:56 p.m. UTC | #1
On 10/16/2018 01:58 PM, Cornelia Huck wrote:
> If ioctl(..., VFIO_DEVICE_RESET) fails, we want to report errno
> instead of ret (which is always -1 on error).
> 
> Fixes Coverity issue CID 1396176.
> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>

makes sense

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>  hw/vfio/ap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index 3962bb74e5..65de952f44 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -142,7 +142,7 @@ static void vfio_ap_reset(DeviceState *dev)
>      ret = ioctl(vapdev->vdev.fd, VFIO_DEVICE_RESET);
>      if (ret) {
>          error_report("%s: failed to reset %s device: %s", __func__,
> -                     vapdev->vdev.name, strerror(ret));
> +                     vapdev->vdev.name, strerror(errno));
>      }
>  }
>  
>
Thomas Huth Oct. 16, 2018, 1:29 p.m. UTC | #2
On 2018-10-16 13:58, Cornelia Huck wrote:
> If ioctl(..., VFIO_DEVICE_RESET) fails, we want to report errno
> instead of ret (which is always -1 on error).
> 
> Fixes Coverity issue CID 1396176.
> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> ---
>  hw/vfio/ap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index 3962bb74e5..65de952f44 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -142,7 +142,7 @@ static void vfio_ap_reset(DeviceState *dev)
>      ret = ioctl(vapdev->vdev.fd, VFIO_DEVICE_RESET);
>      if (ret) {
>          error_report("%s: failed to reset %s device: %s", __func__,
> -                     vapdev->vdev.name, strerror(ret));
> +                     vapdev->vdev.name, strerror(errno));
>      }
>  }
>  
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
Anthony Krowiak Oct. 16, 2018, 2:56 p.m. UTC | #3
On 10/16/2018 07:58 AM, Cornelia Huck wrote:
> If ioctl(..., VFIO_DEVICE_RESET) fails, we want to report errno
> instead of ret (which is always -1 on error).
> 
> Fixes Coverity issue CID 1396176.
> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> ---
>   hw/vfio/ap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index 3962bb74e5..65de952f44 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -142,7 +142,7 @@ static void vfio_ap_reset(DeviceState *dev)
>       ret = ioctl(vapdev->vdev.fd, VFIO_DEVICE_RESET);
>       if (ret) {
>           error_report("%s: failed to reset %s device: %s", __func__,
> -                     vapdev->vdev.name, strerror(ret));
> +                     vapdev->vdev.name, strerror(errno));
>       }
>   }

Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>

>   
>
Cornelia Huck Oct. 16, 2018, 4:44 p.m. UTC | #4
On Tue, 16 Oct 2018 13:58:17 +0200
Cornelia Huck <cohuck@redhat.com> wrote:

> If ioctl(..., VFIO_DEVICE_RESET) fails, we want to report errno
> instead of ret (which is always -1 on error).
> 
> Fixes Coverity issue CID 1396176.
> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> ---
>  hw/vfio/ap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Queued to s390-next.
diff mbox series

Patch

diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index 3962bb74e5..65de952f44 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -142,7 +142,7 @@  static void vfio_ap_reset(DeviceState *dev)
     ret = ioctl(vapdev->vdev.fd, VFIO_DEVICE_RESET);
     if (ret) {
         error_report("%s: failed to reset %s device: %s", __func__,
-                     vapdev->vdev.name, strerror(ret));
+                     vapdev->vdev.name, strerror(errno));
     }
 }