Re: [PATCH 3/9] mfd: pm8xxx: convert to v2 irq interfaces to support hierarchical IRQ chips

From: Linus Walleij
Date: Wed Feb 06 2019 - 08:08:08 EST


Hi Brian!

I found one more bug in this patch, still not the last bug but I'm still
digging around:

On Fri, Jan 25, 2019 at 5:23 PM Brian Masney <masneyb@xxxxxxxxxxxxx> wrote:

> +struct pm_irq_data {
> + int num_irqs;
> + struct irq_chip *irq_chip;
> + void (*irq_handler)(struct irq_desc *desc);
> +};
> +
> struct pm_irq_chip {
> struct regmap *regmap;
> spinlock_t pm_irq_lock;
> struct irq_domain *irqdomain;
> - unsigned int num_irqs;
> unsigned int num_blocks;
> unsigned int num_masters;
> u8 config[0];
> -};
> -
> -struct pm_irq_data {
> - int num_irqs;
> - const struct irq_domain_ops *irq_domain_ops;
> - void (*irq_handler)(struct irq_desc *desc);
> + const struct pm_irq_data *pm_irq_data;
> };

This doesn't work: the config[0] must be the tail element
of the struct since we allocate dynamically the trailing
config[] bytes.

As it looks now, the *pm_irq_data gets overwritten by
the configs and it crashes.

Yours,
Linus Walleij