[PATCH v3 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
[PATCH v3 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 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/misc/ivshmem-pci.c b/hw/misc/ivshmem-pci.c
index c987eebb98..147e8223bb 100644
--- a/hw/misc/ivshmem-pci.c
+++ b/hw/misc/ivshmem-pci.c
@@ -553,8 +553,10 @@ 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)) {
+            close(fd);
+            return;
+        }
     }
 
     if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
-- 
2.50.1 (Apple Git-155)