s390x: even more hardening fixes
v2 cover s390x: even more hardening fixes
A small pile of additional hardening fixes.
v1->v2:
- Collect reviews/acks (Thanks Matt, Christian, Tony!)
- [MR] Add fixes/stable tags to patches 1, 2, 8
- [CB, MR] Drop fixes/stable tags from patches 5, 6
- [CB] Patch 2: Unwind indicators upon re-set, instead of rejecting it
- [MR] Patch 7: Use a temporary variable on g_try_realloc() call
- [MR] Patch 8: Use CCW datastream to increment no-data count
v1: https://lore.kernel.org/qemu-devel/[email protected]/
Eric Farman (9):
virtio-ccw: Limit ISC to MAX_ISC
virtio-ccw: Do not overwrite existing indicators
virtio-ccw: Fix rc check in read configuration path vfio/ap: Clear error object pointer after non-fatal errors vfio/ccw: Clear error object pointer after non-fatal errors hw/intc/s390x: Fix payload to KVM_HAS_DEVICE_ATTR ioctl hw/intc/s390x: Fix check after g_try_realloc s390x/css: Use datastream pointer for checking no-data CCWs s390x/sclp: Reject short headers in PV case
hw/intc/s390_flic_kvm.c | 8 +++++--- hw/s390x/css.c | 27 +++++++++++++++++++-------- hw/s390x/sclp.c | 6 ++++++ hw/s390x/virtio-ccw.c | 29 ++++++++++++++++++++++++++++- hw/vfio/ap.c | 4 ++++ hw/vfio/ccw.c | 2 ++ 6 files changed, 64 insertions(+), 12 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 2/9 virtio-ccw: Do not overwrite existing indicators
The various indicators pointers allow them to be overwritten, but leak any existing structs that might be there. If indicators exist, ensure that they are released before setting the new ones.
Both the regular and adapter interrupt paths check that they aren't being asked to enable interrupts when the other one is enabled, so just do this release once all the potential checks are completed.
--- hw/s390x/virtio-ccw.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
hw/s390x/virtio-ccw.c +21 -0
@@ -582,6 +582,11 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)if (ret) {break ; } +if (dev->indicators) { +/* Need to remove existing indicators first */ +release_indicator (&dev->routes.adapter, dev->indicators); + dev->indicators =NULL ; + } indicators =be64_to_cpu (indicators); dev->indicators =get_indicator (indicators,sizeof (uint64_t )); sch->curr_status.scsw.count = ccw.count -sizeof (indicators);
@@ -606,6 +611,11 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)if (ret) {break ; } +if (dev->indicators2) { +/* Need to remove existing indicators first */ +release_indicator (&dev->routes.adapter, dev->indicators2); + dev->indicators2 =NULL ; + } indicators =be64_to_cpu (indicators); dev->indicators2 =get_indicator (indicators,sizeof (uint64_t )); sch->curr_status.scsw.count = ccw.count -sizeof (indicators);
@@ -666,6 +676,17 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) }else if (thinint.isc >MAX_ISC ) { ret = -ENOSYS ; }else { +if (dev->indicators) { +/* Need to remove existing indicators first */ +release_indicator (&dev->routes.adapter, dev->indicators); + dev->indicators =NULL ; + } +if (dev->summary_indicator) { +/* Need to remove existing indicators first */ +release_indicator (&dev->routes.adapter, + dev->summary_indicator); + dev->summary_indicator =NULL ; + } thinint.ind_bit =be64_to_cpu (thinint.ind_bit); thinint.summary_indicator =be64_to_cpu (thinint.summary_indicator);
Signature · 1 line
2.53.0
PATCH v2 3/9 virtio-ccw: Fix rc check in read configuration path
In reply to Eric FarmanBoth the read and write config paths use wrappers around cds->op_handler, depending on the direction the I/O is flowing. But they expect opposite values in the returned variable to indicate success.
Fix this by unifying those checks, where CCW_CMD_READ_CONF needs to see !ret as success. The end result is some erroneous data in the SCSW response data, but the overall success/failure is correct.
--- hw/s390x/virtio-ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/virtio-ccw.c +1 -1
@@ -475,7 +475,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) }else {virtio_bus_get_vdev_config (&dev->bus, vdev->config); ret =ccw_dstream_write_buf (&sch->cds, vdev->config, len); -if (ret) { +if (!ret) { sch->curr_status.scsw.count = ccw.count - len; } }
Signature · 1 line
2.53.0
PATCH v2 6/9 hw/intc/s390x: Fix payload to KVM_HAS_DEVICE_ATTR ioctl
In reply to Eric FarmanThe ioctl to determine whether KVM_DEV_FLIC_CLEAR_IO_IRQ is present receives the contents of the attribute struct as its payload, rather than a pointer to the payload itself as is convention.
This may result in erroneous errors from the ioctl, which would result in clear_io_supported being false when it otherwise could be used (which is helpful in device recovery).
--- hw/intc/s390_flic_kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/s390_flic_kvm.c +1 -1
@@ -633,7 +633,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)/* Check clear_io_irq support */ test_attr.group =KVM_DEV_FLIC_CLEAR_IO_IRQ ; flic_state->clear_io_supported = !ioctl (flic_state->fd, -KVM_HAS_DEVICE_ATTR , test_attr); +KVM_HAS_DEVICE_ATTR , &test_attr); }static void kvm_s390_flic_reset (DeviceState *dev)
Signature · 1 line
2.53.0
PATCH v2 1/9 virtio-ccw: Limit ISC to MAX_ISC
In reply to Eric FarmanThe interrupt subclass is often defined as a uint8, though in practice it will be within the range of just 0-7. Ensure that a guest-supplied subclass does not extend beyond its expected range, especially when used as an array index.
--- hw/s390x/css.c | 7 ++++++- hw/s390x/virtio-ccw.c | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
hw/s390x/css.c +6 -1
@@ -654,8 +654,13 @@ void css_adapter_interrupt(CssIoAdapterType type, uint8_t isc)S390FLICState *fs =s390_get_flic ();S390FLICStateClass *fsc =s390_get_flic_class (fs);uint32_t io_int_word = (isc <<27 ) |IO_INT_WORD_AI ; -IoAdapter *adapter = channel_subsys.io_adapters[type][isc]; +IoAdapter *adapter; + +if (type >=CSS_IO_ADAPTER_TYPE_NUMS || isc >MAX_ISC ) { +return ; + } + adapter = channel_subsys.io_adapters[type][isc];if (!adapter) {return ; }
hw/s390x/virtio-ccw.c +6 -0
@@ -46,6 +46,10 @@ static int virtio_ccw_dev_post_load(void *opaque, int version_id)CcwDevice *ccw_dev =CCW_DEVICE (dev);CCWDeviceClass *ck =CCW_DEVICE_GET_CLASS (ccw_dev); +if (dev->thinint_isc >MAX_ISC ) { +return -EINVAL ; + } + ccw_dev->sch->driver_data = dev;if (ccw_dev->sch->thinint_active) { dev->routes.adapter.adapter_id = css_get_adapter_id(
@@ -659,6 +663,8 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) }else {if (ccw_dstream_read (&sch->cds, thinint)) { ret = -EFAULT ; + }else if (thinint.isc >MAX_ISC ) { + ret = -ENOSYS ; }else { thinint.ind_bit =be64_to_cpu (thinint.ind_bit); thinint.summary_indicator =
Signature · 1 line
2.53.0
PATCH v2 8/9 s390x/css: Use datastream pointer for checking no-data CCWs
In reply to Eric FarmanThe channel subsystem will reject channel programs that incorporate 256 CCWs without a data transfer, but the existing check to account for this only does so for CCWs with a data address of zero. Other valid CCWs that wouldn't transfer data are not accounted for.
Rather than re-inventing the wheel, use the output of the datastream at the end of the entire CCW parsing tree to indicate whether data was moved or not.
--- hw/s390x/css.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
hw/s390x/css.c +13 -7
@@ -1016,13 +1016,6 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, check_len = !((ccw.flags &CCW_FLAG_SLI ) && !(ccw.flags &CCW_FLAG_DC )); -if (!ccw.cda) { -if (sch->ccw_no_data_cnt ==255 ) { -return -EINVAL ; - } - sch->ccw_no_data_cnt++; - } -/* Look at the command. */ ccw_dstream_init (&sch->cds, &ccw, &(sch->orb));switch (ccw.cmd_code) {
@@ -1110,6 +1103,19 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, } } +/* +* A CCW that transfers no data is allowed, but ensure an upper limit +* is established to prevent long-running channel programs that don't +* move actual data. +*/ +if (ret ==0 && sch->cds.at_byte ==0 ) { +if (sch->ccw_no_data_cnt ==255 ) { + ret = -EINVAL ; + }else { + sch->ccw_no_data_cnt++; + } + } +return ret; }
Signature · 1 line
2.53.0
PATCH v2 4/9 vfio/ap: Clear error object pointer after non-fatal errors
In reply to Eric FarmanRegistering a new IRQ notifier will allocate an error object if needed, and warn_report_err() will release that memory once it's finished. The pointer remains, however, so subsequent errors after the non-fatal errors in vfio_ap_realize() would cause an assertion failure for a non-NULL pointer.
Fix this by clearing the pointer once the warning has been reported, to reset the state of the error objects.
--- hw/vfio/ap.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/vfio/ap.c +4 -0
@@ -247,8 +247,10 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)/* * Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. +* Clear the pointer, since the warning will release it. */ warn_report_err (err); + err =NULL ; }if (!vfio_ap_register_irq_notifier (vapdev,VFIO_AP_CFG_CHG_IRQ_INDEX , &err))
@@ -256,8 +258,10 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)/* * Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. +* Clear the pointer, since the warning will release it. */ warn_report_err (err); + err =NULL ; }return ;
Signature · 1 line
2.53.0
PATCH v2 9/9 s390x/sclp: Reject short headers in PV case
In reply to Eric FarmanAn invalid length in an SCCB header correctly generates a specification exception for the regular (non-PV) codepath that processes an SCLP instruction intercept. The PV case doesn't, even though such a thing should already be sanitized. Since a short length will cause problems later down the line with the storage that will be allocated based on that size, put up a defensive check and return if it is too short.
--- hw/s390x/sclp.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/s390x/sclp.c +6 -0
@@ -277,6 +277,11 @@ int sclp_service_call_protected(S390CPU *cpu, uint64_t sccb, uint32_t code)s390_cpu_pv_mem_read (env_archcpu (env),0 , &header,sizeof (SCCBHeader)); +/* Do nothing if the header appears malformed */ +if (be16_to_cpu (header.length) <sizeof (SCCBHeader)) { + goto out_no_write; + } + work_sccb =g_malloc0 (be16_to_cpu (header.length));s390_cpu_pv_mem_read (env_archcpu (env),0 , work_sccb,be16_to_cpu (header.length));
@@ -290,6 +295,7 @@ int sclp_service_call_protected(S390CPU *cpu, uint64_t sccb, uint32_t code) out_write:s390_cpu_pv_mem_write (env_archcpu (env),0 , work_sccb,be16_to_cpu (header.length)); +out_no_write: sclp_c->service_interrupt (sclp,SCLP_PV_DUMMY_ADDR );return 0 ; }
Signature · 1 line
2.53.0
PATCH v2 7/9 hw/intc/s390x: Fix check after g_try_realloc
In reply to Eric FarmanThe loop to store pending IRQs uses g_try_realloc() to expand the buffer being used, but the returned address is stored in a pointer-to-pointer, thus the check is supposed to be examining the contents of the pointer, and not the pointer itself.
Define a temporary variable to catch and test the returned pointer. If it's NULL, return to the caller to perform the free on the unmodified buffer. If it's not NULL, store it in the caller's pointer and restart the loop against the new struct.
--- hw/intc/s390_flic_kvm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/intc/s390_flic_kvm.c +4 -2
@@ -254,6 +254,7 @@ static int __get_all_irqs(KVMS390FLICState *flic, void **buf, int len) { int r; +void *realloc =NULL ; do { /* returns -ENOMEM if buffer is too small and number
@@ -263,10 +264,11 @@ static int __get_all_irqs(KVMS390FLICState *flic,break ; } len *=2 ; - *buf =g_try_realloc (*buf, len); -if (!buf) { + realloc =g_try_realloc (*buf, len); +if (!realloc) {return -ENOMEM ; } + *buf = realloc; }while (r == -ENOMEM && len <=KVM_S390_FLIC_MAX_BUFFER );return r;
Signature · 1 line
2.53.0
PATCH v2 5/9 vfio/ccw: Clear error object pointer after non-fatal errors
In reply to Eric FarmanJust like in vfio/ap, there is a non-fatal message that could be generated, with a stale pointer in the error object variable.
Unlike vfio/ap, there is no secondary message that could attempt to use it. Clear it in the same way, in case that ever changes.
--- hw/vfio/ccw.c | 2 ++ 1 file changed, 2 insertions(+)
hw/vfio/ccw.c +2 -0
@@ -604,8 +604,10 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)/* * Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. +* Clear the pointer, since the warning will release it. */ warn_report_err (err); + err =NULL ; }return ;
Signature · 1 line
2.53.0
Re: [PATCH v2 7/9] hw/intc/s390x: Fix check after g_try_realloc
In reply to Eric FarmanAm 21.09.26 um 20:43 schrieb Eric Farman:
Quoted 22 lines
The loop to store pending IRQs uses
g_try_realloc()to expand the buffer being used, but the returned address is stored in a pointer-to-pointer, thus the check is supposed to be examining the contents of the pointer, and not the pointer itself.Define a temporary variable to catch and test the returned pointer. If it's NULL, return to the caller to perform the free on the unmodified buffer. If it's not NULL, store it in the caller's pointer and restart the loop against the new struct.
Fixes 3a553fc658 ("s390x/kvm: implement floating-interrupt controller device")Signed-off-by Eric Farman <[email protected]>--- hw/intc/s390_flic_kvm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)hw/intc/s390_flic_kvm.c +0
-0
hw/intc/s390_flic_kvm.c static int __get_all_irqs(KVMS390FLICState *flic, · line 257
Quoted 4 lines
hw/intc/s390_flic_kvm.c +1
-0@@ -254,6 +254,7 @@ static int __get_all_irqs(KVMS390FLICState *flic, void **buf, int len) {int r; +void *realloc =NULL ;
Ideally use a different name to avoid shadowing the libc function. (e.g. new_buf) Other than that
Quoted 17 lines
hw/intc/s390_flic_kvm.c +3
-2do { /* returns -ENOMEM if buffer is too small and number@@ -263,10 +264,11 @@ static int __get_all_irqs(KVMS390FLICState *flic,break ; } len *=2 ; - *buf =g_try_realloc (*buf, len); -if (!buf) { + realloc =g_try_realloc (*buf, len); +if (!realloc) {return -ENOMEM ; } + *buf = realloc; }while (r == -ENOMEM && len <=KVM_S390_FLIC_MAX_BUFFER );return r;
Re: [PATCH v2 8/9] s390x/css: Use datastream pointer for checking no-data CCWs
In reply to Eric FarmanAm 21.09.26 um 20:43 schrieb Eric Farman:
Quoted 35 lines
The channel subsystem will reject channel programs that incorporate 256 CCWs without a data transfer, but the existing check to account for this only does so for CCWs with a data address of zero. Other valid CCWs that wouldn't transfer data are not accounted for.
Rather than re-inventing the wheel, use the output of the datastream at the end of the entire CCW parsing tree to indicate whether data was moved or not.
Fixes e8601dd5d0 ("s390x/css: catch ccw sequence errors")Signed-off-by Eric Farman <[email protected]>--- hw/s390x/css.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)hw/s390x/css.c +0
-7@@ -1016,13 +1016,6 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, check_len = !((ccw.flags &CCW_FLAG_SLI ) && !(ccw.flags &CCW_FLAG_DC )); -if (!ccw.cda) { -if (sch->ccw_no_data_cnt ==255 ) { -return -EINVAL ; - } - sch->ccw_no_data_cnt++; - } -/* Look at the command. */ ccw_dstream_init (&sch->cds, &ccw, &(sch->orb));switch (ccw.cmd_code) {
hw/s390x/css.c static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, · line 1105
Quoted 3 lines
hw/s390x/css.c +0
-0@@ -1110,6 +1103,19 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, } }
These two context lines are the end of
if (ret == 0) {
if (ccw.flags & CCW_FLAG_CC) {
sch->channel_prog += 8;
ret = -EAGAIN;
}
}so by the time we get here, every successfully executed CCW that has command chaining set already has ret == -EAGAIN.
Quoted 6 lines
hw/s390x/css.c +6
-0+/* +* A CCW that transfers no data is allowed, but ensure an upper limit +* is established to prevent long-running channel programs that don't +* move actual data. +*/ +if (ret ==0 && sch->cds.at_byte ==0 ) {
hw/s390x/css.c static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, · line 1121
Quoted 10 lines
hw/s390x/css.c +7
-0+if (sch->ccw_no_data_cnt ==255 ) { + ret = -EINVAL ; + }else { + sch->ccw_no_data_cnt++; + } + } +return ret; }
Which means this never fires for a chained CCW. The only CCW that can still be counted is the last one of the program (no CC), and ccw_no_data_cnt is reset on every SSCH, so the counter can never reach
255. A chain of 100000 NOOPs with CC now runs to completion, while HEAD rejects it at the 256th CCW when cda is zero. As posted this removes the protection from e8601dd5d0 rather than extending it.
Moving the check above the CC block (right after last_cmd_valid = true) should do it, no?
Re: [PATCH v2 6/9] hw/intc/s390x: Fix payload to KVM_HAS_DEVICE_ATTR ioctl
In reply to Eric FarmanAm 21.09.26 um 20:43 schrieb Eric Farman:
Quoted 9 lines
The ioctl to determine whether
KVM_DEV_FLIC_CLEAR_IO_IRQis present receives the contents of the attribute struct as its payload, rather than a pointer to the payload itself as is convention.This may result in erroneous errors from the ioctl, which would result in
clear_io_supportedbeing false when it otherwise could be used (which is helpful in device recovery).Reviewed-by Matthew Rosato <[email protected]>
Quoted 18 lines
Signed-off-by Eric Farman <[email protected]>--- hw/intc/s390_flic_kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/intc/s390_flic_kvm.c +1
-1@@ -633,7 +633,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)/* Check clear_io_irq support */ test_attr.group =KVM_DEV_FLIC_CLEAR_IO_IRQ ; flic_state->clear_io_supported = !ioctl (flic_state->fd, -KVM_HAS_DEVICE_ATTR , test_attr); +KVM_HAS_DEVICE_ATTR , &test_attr); }static void kvm_s390_flic_reset (DeviceState *dev)
Re: [PATCH v2 8/9] s390x/css: Use datastream pointer for checking no-data CCWs
In reply to Christian BorntraegerQuoted 76 lines · Christian Borntraeger
Am 21.09.26 um 20:43 schrieb Eric Farman:
Quoted 34 lines
The channel subsystem will reject channel programs that incorporate 256 CCWs without a data transfer, but the existing check to account for this only does so for CCWs with a data address of zero. Other valid CCWs that wouldn't transfer data are not accounted for.
Rather than re-inventing the wheel, use the output of the datastream at the end of the entire CCW parsing tree to indicate whether data was moved or not.
Fixes e8601dd5d0 ("s390x/css: catch ccw sequence errors")Signed-off-by Eric Farman <[email protected]>---
hw/s390x/css.c| 20 +++++++++++++-------1 file changed, 13 insertions(+), 7 deletions(-)hw/s390x/css.c +0
-7@@ -1016,13 +1016,6 @@ static int css_interpret_ccw(SubchDev *sch,hwaddr ccw_addr, check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC)); - if (!ccw.cda) { - if (sch->ccw_no_data_cnt == 255) { - return -EINVAL; - } - sch->ccw_no_data_cnt++; - } - /* Look at the command. */ ccw_dstream_init(&sch->cds, &ccw, &(sch->orb)); switch (ccw.cmd_code) {hw/s390x/css.c static int css_interpret_ccw(SubchDev *sch, · line 1105
Quoted 3 lines
hw/s390x/css.c +0
-0@@ -1110,6 +1103,19 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, } }These two context lines are the end of
if (ret == 0) {
if (ccw.flags &CCW_FLAG_CC) {
sch->channel_prog+= 8;
ret =-EAGAIN;
}
}so by the time we get here, every successfully executed CCW that has command chaining set already has ret ==
-EAGAIN.Quoted 9 lines
hw/s390x/css.c +2
-0+ /* +* A CCW that transfers no data is allowed, but ensure an upper limit
+ * is established to prevent long-running channel programs that don't
+ * move actual data.
+ */
+ if (ret == 0 &&sch->cds.at_byte== 0) {
+ if (sch->ccw_no_data_cnt== 255) {Quoted 8 lines
+ ret =
-EINVAL;
+ } else {
+ sch->ccw_no_data_cnt++;
+ }
+ }
+
return ret;
}Which means this never fires for a chained CCW. The only CCW that can still be counted is the last one of the program (no CC), and
ccw_no_data_cntis reset on every SSCH, so the counter can never reach
255. A chain of 100000 NOOPs with CC now runs to completion, while HEAD rejects it at the 256th CCW when cda is zero. As posted this removes the protection frome8601dd5d0rather than extending it.
Quoted 3 lines
Moving the check above the CC block (right after
last_cmd_valid= true) should do it, no?
Oops, I looked at that and still missed it... Will fix on a v3.
Re: [PATCH v2 2/9] virtio-ccw: Do not overwrite existing indicators
In reply to Eric FarmanQuoted 4 lines · Eric Farman
The various indicators pointers allow them to be overwritten, but leak any existing structs that might be there. If indicators exist, ensure that they are released before setting the new ones.
Quoted 8 lines
Both the regular and adapter interrupt paths check that they aren't being asked to enable interrupts when the other one is enabled, so just do this release once all the potential checks are completed.
Fixes 7bca3892cb ("s390x/virtio-ccw: reference-counted indicators")Signed-off-by Eric Farman <[email protected]>
Re: [PATCH v2 7/9] hw/intc/s390x: Fix check after g_try_realloc
In reply to Eric FarmanQuoted 5 lines · Eric Farman
The loop to store pending IRQs uses
g_try_realloc()to expand the buffer being used, but the returned address is stored in a pointer-to-pointer, thus the check is supposed to be examining the contents of the pointer, and not the pointer itself.
Quoted 8 lines
Define a temporary variable to catch and test the returned pointer. If it's NULL, return to the caller to perform the free on the unmodified buffer. If it's not NULL, store it in the caller's pointer and restart the loop against the new struct.
Fixes 3a553fc658 ("s390x/kvm: implement floating-interrupt controller device")Signed-off-by Eric Farman <[email protected]>
With Christian's suggestion addressed: