[PATCH v2 2/2] hw/misc/ivshmem-pci: Check error after setup_interrupt() in process_msg_connect()

David Hamilton posted 2 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH v2 2/2] hw/misc/ivshmem-pci: Check error after setup_interrupt() in process_msg_connect()
Posted by David Hamilton 1 month, 2 weeks ago
setup_interrupt() can fail and report via errp, but
process_msg_connect() was ignoring the error and continuing
to ivshmem_add_eventfd(). Check the bool return to avoid
operating on a vector whose interrupt setup failed.

Resolves the TODO comment at the call site.

Signed-off-by: David Hamilton <dahamilt0@gmail.com>
---
 hw/misc/ivshmem-pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/misc/ivshmem-pci.c b/hw/misc/ivshmem-pci.c
index c987eebb98..f1262fa5f7 100644
--- a/hw/misc/ivshmem-pci.c
+++ b/hw/misc/ivshmem-pci.c
@@ -553,8 +553,9 @@ static void process_msg_connect(IVShmemState *s, uint16_t posn, int fd,
     }
 
     if (posn == s->vm_id) {
-        setup_interrupt(s, vector, errp);
-        /* TODO do we need to handle the error? */
+        if (!setup_interrupt(s, vector, errp)) {
+            return;
+        }
     }
 
     if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
-- 
2.50.1 (Apple Git-155)
Re: [PATCH v2 2/2] hw/misc/ivshmem-pci: Check error after setup_interrupt() in process_msg_connect()
Posted by Markus Armbruster 1 month, 2 weeks ago
David Hamilton <dahamilt0@gmail.com> writes:

> setup_interrupt() can fail and report via errp, but
> process_msg_connect() was ignoring the error and continuing
> to ivshmem_add_eventfd(). Check the bool return to avoid
> operating on a vector whose interrupt setup failed.
>
> Resolves the TODO comment at the call site.
>
> Signed-off-by: David Hamilton <dahamilt0@gmail.com>
> ---
>  hw/misc/ivshmem-pci.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/misc/ivshmem-pci.c b/hw/misc/ivshmem-pci.c
> index c987eebb98..f1262fa5f7 100644
> --- a/hw/misc/ivshmem-pci.c
> +++ b/hw/misc/ivshmem-pci.c
> @@ -553,8 +553,9 @@ static void process_msg_connect(IVShmemState *s, uint16_t posn, int fd,
>      }
>  
>      if (posn == s->vm_id) {
> -        setup_interrupt(s, vector, errp);
> -        /* TODO do we need to handle the error? */
> +        if (!setup_interrupt(s, vector, errp)) {

Any cleanup needed here?  Error returns above close(fd).

> +            return;
> +        }
>      }
>  
>      if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {