qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC/PATCH v0 01/12] hw/arm/virt: Avoid NULL pointer de-reference


From: Srivatsa Vaddagiri
Subject: Re: [RFC/PATCH v0 01/12] hw/arm/virt: Avoid NULL pointer de-reference
Date: Thu, 12 Oct 2023 17:54:00 +0530

* Philippe Mathieu-Daud? <philmd@linaro.org> [2023-10-12 06:30:24]:

> Hi Srivatsa,
> 
> (+Markus/Peter for QOM fu)
> 
> On 11/10/23 18:52, Srivatsa Vaddagiri wrote:
> > Avoid dereferencing a NULL pointer that its_class_name() could return.
> 
> While your patch is correct, there is some code smell
> around its_class_name(). IMHO a foo_class_name() handler
> should never return NULL.

I saw its_class_name() returning NULL for KVM in some case and took the
same route for Gunyah (as ITS is not supported atm):

const char *its_class_name(void)
{
    if (kvm_irqchip_in_kernel()) {
        /* KVM implementation requires this capability */
        return kvm_direct_msi_enabled() ? "arm-its-kvm" : NULL;
    } else if (gunyah_enabled()) { 
        /* ITS is not yet supported */
        return NULL; 
}

I guess I could have its_class_name() return "arm-gicv3-its" (for Gunyah case)
and set vms->tcg_its to false, which will avoid the NULL-pointer deref I was
hitting.

I will drop this patch in next version in that case.

- vatsa



reply via email to

[Prev in Thread] Current Thread [Next in Thread]