Re: [PATCH v2] genirq/irqdesc: fix WARNING in irq_sysfs_del()

From: Greg KH
Date: Tue Nov 29 2022 - 02:54:36 EST


On Mon, Nov 28, 2022 at 07:55:17PM +0100, Thomas Gleixner wrote:
> On Mon, Nov 28 2022 at 18:20, Greg KH wrote:
> > On Mon, Nov 28, 2022 at 11:16:12PM +0800, Yang Yingliang wrote:
> >> @@ -292,6 +292,8 @@ static void irq_sysfs_add(int irq, struct irq_desc *desc)
> >> */
> >> if (kobject_add(&desc->kobj, irq_kobj_base, "%d", irq))
> >> pr_warn("Failed to add kobject for irq %d\n", irq);
> >> + else
> >> + desc->sysfs_added = true;
> >
> > Wait, no. Why are you just not properly failing and unwinding here?
>
> There is an issue here.
>
> sysfs is not yet available when the first interrupts are allocated. So
> we add the sysfs files late in the boot.
>
> So what can we do if that fails? Unwind the boot process? :)
>
> Sure we can fail after sysfs has been initialized, but that's
> inconsistent at best and we need some special treatment for the late add
> anyway.
>
> I agree that this is not pretty, but the resulting choices are all but
> pretty.

Ah, ok, that makes more sense. In this case, yes, the flag should be
fine to have.

Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>