Re: [PATCH] genirq/devres: Simplify API devm_free_irq() implementation

From: Thomas Gleixner
Date: Fri Oct 18 2024 - 07:02:23 EST


On Fri, Oct 18 2024 at 17:28, quic zijuhu wrote:
> On 10/18/2024 4:57 PM, Thomas Gleixner wrote:
> if irq to free was ever requested by devm_request_irq()
> then both logic is exactly same.
>
> otherwise, actually change devres_free_irq()'s logic from
>
> if (irq is not requested by devm_request_irq() {
> warn;
> }
> free_irq()
>
> To
>
> if (irq is not requested by devm_request_irq() {
> warn;
> return;
> }
>

Ah, you are right. I thought there is a return there.

So you want to explain it maybe this way:

If devres_destroy() does not find a matching devres entry, then
devm_free_irq() emits a warning and tries to free the interrupt.

That's wrong as devm_free_irq() should only undo what
devm_request_irq() set up.

Replace devres_destroy() with a call to devres_release() which only
invokes the release function (free_irq()) in case that a matching
devres entry was found.

Or something like that.

Thanks,

tglx