Skip to contentSkip to conversation

xen/domain: fail vcpu_create() if init_waitqueue_vcpu() fails

PATCH In review Juergen Gross 2 participants 2 messages Nov 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/domain: fail vcpu_create() if init_waitqueue_vcpu() fails

init_waitqueue_vcpu() can fail in case of memory shortage. Don't let vcpu_create() succeed in this case.

As destroy_waitqueue_vcpu() is tolerating a NULL waitqueue_vcpu, just reuse the existing fail_wq label.

Fixes 9b231b6bc20b ("Wait queues, allowing conditional sleep in hypervisor context.")
---
 xen/common/domain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/domain.c +2 -1
index f3a2634d5f..060f0e7a9d 100644
@@ -496,7 +496,8 @@ struct vcpu *vcpu_create(struct domain *d, unsigned int vcpu_id)
         v->runstate.state_entry_time = NOW();
         set_bit(_VPF_down, &v->pause_flags);
         vcpu_info_reset(v);
-        init_waitqueue_vcpu(v);
+        if ( init_waitqueue_vcpu(v) != 0 )
+            goto fail_wq;
 
         if ( vmtrace_alloc_buffer(v) != 0 )
             goto fail_wq;
Signature · 1 line
2.56.0
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · Juergen Gross

init_waitqueue_vcpu() can fail in case of memory shortage. Don't let vcpu_create() succeed in this case.

As destroy_waitqueue_vcpu() is tolerating a NULL waitqueue_vcpu, just reuse the existing fail_wq label.

Fixes 9b231b6bc20b ("Wait queues, allowing conditional sleep in hypervisor context.")
---
 xen/common/domain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/domain.c +0 -0
index f3a2634d5f..060f0e7a9d 100644

xen/common/domain.c struct vcpu *vcpu_create(struct domain *d, unsigned int vcpu_id) · line 503

Quoted 9 lines
xen/common/domain.c +2 -1
@@ -496,7 +496,8 @@ struct vcpu *vcpu_create(struct domain *d, unsigned int vcpu_id)
         v->runstate.state_entry_time = NOW();
         set_bit(_VPF_down, &v->pause_flags);
         vcpu_info_reset(v);
-        init_waitqueue_vcpu(v);
+        if ( init_waitqueue_vcpu(v) != 0 )
+            goto fail_wq;
 
         if ( vmtrace_alloc_buffer(v) != 0 )
             goto fail_wq;

The waitqueue infrastructure is on the verge of getting purged, but this clearly wants backporting.

~Andrew