[PATCH 06/40] s390x: prevent crash if given invalid CPU#

Marc-André Lureau posted 40 patches 2 months, 3 weeks ago
There is a newer version of this series
[PATCH 06/40] s390x: prevent crash if given invalid CPU#
Posted by Marc-André Lureau 2 months, 3 weeks ago
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/s390x/s390-virtio-ccw.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 4d35f9b10bc..d27d82a378a 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -729,6 +729,11 @@ static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
 {
     CPUState *cs = qemu_get_cpu(cpu_index);
 
+    if (!cs) {
+        error_setg(errp, "CPU %d does not exist", cpu_index);
+        return;
+    }
+
     s390_cpu_restart(S390_CPU(cs));
 }
 

-- 
2.54.0


Re: [PATCH 06/40] s390x: prevent crash if given invalid CPU#
Posted by Eric Farman 2 months, 3 weeks ago
On Thu, 2026-05-21 at 01:49 +0400, Marc-André Lureau wrote:
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/s390x/s390-virtio-ccw.c | 5 +++++
>  1 file changed, 5 insertions(+)

Straightforward defensive check.

Reviewed-by: Eric Farman <farman@linux.ibm.com>