Skip to contentSkip to conversation

migration: Unlock mutex in error case

PATCH Superseded Juan Quintela 4 participants 5 messages Nov 2, 2023 – Nov 3, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 migration: Unlock mutex in error case

We were not unlocking bitmap mutex on the error case. Coverity discovered the problem.

Fixes a2326705e5 ("migration: Stop migration immediately in RDMA error paths")
---
 migration/ram.c | 1 +
 1 file changed, 1 insertion(+)
migration/ram.c +1 -0
index 34724e8fe8..8c4df60f29 100644
@@ -3040,6 +3040,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
         ret = rdma_registration_start(f, RAM_CONTROL_ROUND);
         if (ret < 0) {
             qemu_file_set_error(f, ret);
+            qemu_mutex_unlock(&rs->bitmap_mutex);
             goto out;
         }
 
Signature · 1 line
2.41.0
#1 lore raw
Quoted 14 lines · Juan Quintela

We were not unlocking bitmap mutex on the error case. Coverity discovered the problem.

Fixes a2326705e5 ("migration: Stop migration immediately in RDMA error paths")
---
 migration/ram.c | 1 +
 1 file changed, 1 insertion(+)
migration/ram.c +0 -0
index 34724e8fe8..8c4df60f29 100644

migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 3043

Quoted 4 lines
migration/ram.c +1 -0
@@ -3040,6 +3040,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
         ret = rdma_registration_start(f, RAM_CONTROL_ROUND);
         if (ret < 0) {
             qemu_file_set_error(f, ret);
+            qemu_mutex_unlock(&rs->bitmap_mutex);

I see the function uses the WITH_RCU_READ_LOCK_GUARD() macro to autofree the RCU lock so why not use WITH_QEMU_LOCK_GUARD() instead of manually checking the error cases?

Quoted 2 lines
migration/ram.c +0 -0
             goto out;
         }
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#2 lore raw
Quoted 11 lines · Alex Bennée
Quoted 9 lines · Juan Quintela

We were not unlocking bitmap mutex on the error case. Coverity discovered the problem.

Fixes a2326705e5 ("migration: Stop migration immediately in RDMA error paths")
---
 migration/ram.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 3043

Quoted 9 lines
migration/ram.c +1 -0
index 34724e8fe8..8c4df60f29 100644
@@ -3040,6 +3040,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
         ret = rdma_registration_start(f, RAM_CONTROL_ROUND);
         if (ret < 0) {
             qemu_file_set_error(f, ret);
+            qemu_mutex_unlock(&rs->bitmap_mutex);

I see the function uses the WITH_RCU_READ_LOCK_GUARD() macro to autofree the RCU lock so why not use WITH_QEMU_LOCK_GUARD() instead of manually checking the error cases?

You are right.

Changing to that.

Later, Juan.

Reviewed-by on v1 1/1
#4 lore raw
In reply to Juan Quintela
Quoted 14 lines · Juan Quintela

We were not unlocking bitmap mutex on the error case. Coverity discovered the problem.

Fixes a2326705e5 ("migration: Stop migration immediately in RDMA error paths")
---
 migration/ram.c | 1 +
 1 file changed, 1 insertion(+)
migration/ram.c +0 -0
index 34724e8fe8..8c4df60f29 100644

migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 3045

Quoted 6 lines
migration/ram.c +1 -0
@@ -3040,6 +3040,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
         ret = rdma_registration_start(f, RAM_CONTROL_ROUND);
         if (ret < 0) {
             qemu_file_set_error(f, ret);
+            qemu_mutex_unlock(&rs->bitmap_mutex);
             goto out;
         }
Signature · 1 line
Peter Xu