[v4,12/17] vfio/platform: fix a wrong returned value in vfio_populate_device
diff mbox

Message ID 1475498477-2695-13-git-send-email-eric.auger@redhat.com
State New
Headers show

Commit Message

Auger Eric Oct. 3, 2016, 12:41 p.m. UTC
In case the vfio_init_intp fails we currently do not return an
error value. This patch fixes the bug. The returned value is not
explicit but in practice the error object is the one used to
report the error to the end-user and the actual returned error
value is not used.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 hw/vfio/platform.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Markus Armbruster Oct. 4, 2016, 12:48 p.m. UTC | #1
Eric Auger <eric.auger@redhat.com> writes:

> In case the vfio_init_intp fails we currently do not return an
> error value. This patch fixes the bug. The returned value is not
> explicit but in practice the error object is the one used to
> report the error to the end-user and the actual returned error
> value is not used.

The function's contract permits this by neglecting to say anything about
the return value %-)

The callers don't actually care about the value.

> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
>  hw/vfio/platform.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
> index 1a35da0..484e31f 100644
> --- a/hw/vfio/platform.c
> +++ b/hw/vfio/platform.c
> @@ -508,6 +508,7 @@ static int vfio_populate_device(VFIODevice *vbasedev, Error **errp)
>                                                      irq.flags);
>              intp = vfio_init_intp(vbasedev, irq, errp);
>              if (!intp) {
> +                ret = -1;
>                  goto irq_err;
>              }
>          }
Auger Eric Oct. 6, 2016, 4:12 p.m. UTC | #2
Hi,

On 04/10/2016 14:48, Markus Armbruster wrote:
> Eric Auger <eric.auger@redhat.com> writes:
> 
>> In case the vfio_init_intp fails we currently do not return an
>> error value. This patch fixes the bug. The returned value is not
>> explicit but in practice the error object is the one used to
>> report the error to the end-user and the actual returned error
>> value is not used.
> 
> The function's contract permits this by neglecting to say anything about
> the return value %-)
Yes the error is severe enough to tear things down. I dared to keep it
as is since the error now is reported in the Error object.

Thanks

Eric
> 
> The callers don't actually care about the value.
> 
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>>  hw/vfio/platform.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
>> index 1a35da0..484e31f 100644
>> --- a/hw/vfio/platform.c
>> +++ b/hw/vfio/platform.c
>> @@ -508,6 +508,7 @@ static int vfio_populate_device(VFIODevice *vbasedev, Error **errp)
>>                                                      irq.flags);
>>              intp = vfio_init_intp(vbasedev, irq, errp);
>>              if (!intp) {
>> +                ret = -1;
>>                  goto irq_err;
>>              }
>>          }
>

Patch
diff mbox

diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index 1a35da0..484e31f 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -508,6 +508,7 @@  static int vfio_populate_device(VFIODevice *vbasedev, Error **errp)
                                                     irq.flags);
             intp = vfio_init_intp(vbasedev, irq, errp);
             if (!intp) {
+                ret = -1;
                 goto irq_err;
             }
         }