On 9/16/26 4:32 PM, Eric Farman wrote:
> Registering 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.
> 
> Cc: Anthony Krowiak <[email protected]>
> Cc: [email protected]
> Fixes: 1360b2ad1f ("s390x/ap: Wire up the device request notifier interface")
> Fixes: 0fb8a62fe4 ("hw/vfio/ap: notification handler for AP config changed 
> event")
> Signed-off-by: Eric Farman <[email protected]>
> ---
>  hw/vfio/ap.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index 6e2a1223ea..2926e04ad4 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -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;

Technically this one is unnecessary since we're about to return, but I
like it for future-proofing:

Reviewed-by: Matthew Rosato <[email protected]>



Reply via email to