Re: [RFC PATCH v3 19/37] irqchip: Add irq-kvx-apic-gic driver

From: Krzysztof Kozlowski
Date: Mon Jul 22 2024 - 08:29:04 EST


On 22/07/2024 11:41, ysionneau@xxxxxxxxxxxxx wrote:
> From: Yann Sionneau <ysionneau@xxxxxxxxxxxxx>
>

...

> +
> +static int __init kvx_init_apic_gic(struct device_node *node,
> + struct device_node *parent)
> +{
> + struct kvx_apic_gic *gic;
> + int ret;
> + unsigned int irq;
> +
> + if (!parent) {
> + pr_err("kvx apic gic does not have parent\n");

How is this possible? Aren't you controlling the code being executed?

> + return -EINVAL;
> + }
> +
> + gic = kzalloc(sizeof(*gic), GFP_KERNEL);
> + if (!gic)
> + return -ENOMEM;
> +
> + if (of_property_read_u32(node, "kalray,intc-nr-irqs",
> + &gic->input_nr_irqs))

There is no such property. Also, there shouldn't be anyway...

> + gic->input_nr_irqs = KVX_GIC_INPUT_IT_COUNT;
> +
> + if (WARN_ON(gic->input_nr_irqs > KVX_GIC_INPUT_IT_COUNT)) {

Why? Please, drop all these WARN_ON from here and other patches. WARN_ON
is for cases which cannot happen, as it might panic entire system.

Instead, handle the case properly.

> + ret = -EINVAL;
> + goto err_kfree;
> + }
> +
> + gic->base = of_io_request_and_map(node, 0, node->name);
> + if (!gic->base) {
> + ret = -EINVAL;
> + goto err_kfree;
> + }
> +
> + raw_spin_lock_init(&gic->lock);
> + apic_gic_init(gic);


Best regards,
Krzysztof