On Wed Oct 8, 2025 at 8:45 PM CEST, Joel Fernandes wrote:
> Great idea, so paraphrasing for myself, your point is with the above code,
> someone could theoretically do:
>
>   1. Call new() directly on IrqVectorRegistration (bypassing 
> alloc_irq_vectors()).
>   2. Forget to call devres::register().
>   3. Store the IrqVectorRegistration somewhere.
>   4. Device gets unbound.
>   5. Later when IrqVectorRegistration::drop() runs, it tries to free vectors 
> on
> a device that's gone.
>
> Is that right?

Correct -- however, it's less about this could actually happen, since it's not a
public type. But it safes you writing invariants, unsafe calls, makes the code
cleaner and more self-contained.

> So a better approach as you mentioned, is to do the devres registration during
> the construction of the IrqVectorRegistration, so there's no way to do one
> without the other. Did I get that right? Anyway great point and I have made 
> this
> change, thanks!

Great, thanks!

Reply via email to