Skip to contentSkip to conversation

vfio: don't ignore return value of migrate_add_blocker

PATCH In review Jens Freimann 4 participants 4 messages Nov 14, 2019 – Nov 19, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio: don't ignore return value of migrate_add_blocker

When an error occurs in migrate_add_blocker() it sets a negative return value and uses error pointer we pass in. Instead of just looking at the error pointer check for a negative return value and avoid a coverity error because the return value is set but never used. This fixes CID 1407219.

Fixes f045a0104c8c ("vfio: unplug failover primary device before

migration")

---
 hw/vfio/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/pci.c +1 -1
index e6569a7968..ed01774673 100644
@@ -2737,7 +2737,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
         error_setg(&vdev->migration_blocker,
                 "VFIO device doesn't support migration");
         ret = migrate_add_blocker(vdev->migration_blocker, &err);
-        if (err) {
+        if (ret) {
             error_propagate(errp, err);
             error_free(vdev->migration_blocker);
             return;
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Jens Freimann

When an error occurs in migrate_add_blocker() it sets a negative return value and uses error pointer we pass in. Instead of just looking at the error pointer check for a negative return value and avoid a coverity error because the return value is set but never used. This fixes CID 1407219.

Fixes f045a0104c8c ("vfio: unplug failover primary device before

migration")

---
  hw/vfio/pci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/pci.c +0 -0
index e6569a7968..ed01774673 100644

hw/vfio/pci.c static void vfio_realize(PCIDevice *pdev, Error **errp) · line 2743

Quoted 8 lines
hw/vfio/pci.c +1 -1
@@ -2737,7 +2737,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
          error_setg(&vdev->migration_blocker,
                  "VFIO device doesn't support migration");
          ret = migrate_add_blocker(vdev->migration_blocker, &err);
-        if (err) {
+        if (ret) {
              error_propagate(errp, err);
              error_free(vdev->migration_blocker);
              return;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jens Freimann
Quoted 6 lines · Jens Freimann

When an error occurs in migrate_add_blocker() it sets a negative return value and uses error pointer we pass in. Instead of just looking at the error pointer check for a negative return value and avoid a coverity error because the return value is set but never used. This fixes CID 1407219.

Quoted 6 lines
Fixes f045a0104c8c ("vfio: unplug failover primary device before

migration")

---
 hw/vfio/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#3 lore raw
In reply to Jens Freimann
Quoted 18 lines · On Thu, 14 Nov 2019 14:34:49 +0100 Jens Freimann <[email protected]> wrote:

When an error occurs in migrate_add_blocker() it sets a negative return value and uses error pointer we pass in. Instead of just looking at the error pointer check for a negative return value and avoid a coverity error because the return value is set but never used. This fixes CID 1407219.

Fixes f045a0104c8c ("vfio: unplug failover primary device before

migration")

---
 hw/vfio/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/pci.c +0 -0
index e6569a7968..ed01774673 100644

hw/vfio/pci.c static void vfio_realize(PCIDevice *pdev, Error **errp) · line 2743

Quoted 8 lines
hw/vfio/pci.c +1 -1
@@ -2737,7 +2737,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
         error_setg(&vdev->migration_blocker,
                 "VFIO device doesn't support migration");
         ret = migrate_add_blocker(vdev->migration_blocker, &err);
-        if (err) {
+        if (ret) {
             error_propagate(errp, err);
             error_free(vdev->migration_blocker);
             return;

Slightly late notice, but I did include this in my last pull request and it's included in v4.2.0-rc2 with Stefano and Philippe's R-b. Thanks,

Alex