[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DDD6EEB2MJGJ.1UNH7GMXXU9WC@kernel.org>
Date: Wed, 08 Oct 2025 21:09:04 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Joel Fernandes" <joelagnelf@...dia.com>
Cc: <linux-kernel@...r.kernel.org>, <dri-devel@...ts.freedesktop.org>,
<nouveau@...ts.freedesktop.org>, <rust-for-linux@...r.kernel.org>,
<linux-pci@...r.kernel.org>, <acourbot@...dia.com>, "Alistair Popple"
<apopple@...dia.com>, "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
<alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
<gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <lossin@...nel.org>, "Andreas
Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
"Trevor Gross" <tmgross@...ch.edu>, "David Airlie" <airlied@...il.com>,
"Simona Vetter" <simona@...ll.ch>, "John Hubbard" <jhubbard@...dia.com>,
"Timur Tabi" <ttabi@...dia.com>, <joel@...lfernandes.org>, "Daniel Almeida"
<daniel.almeida@...labora.com>, "Bjorn Helgaas" <bhelgaas@...gle.com>,
Krzysztof Wilczyński <kwilczynski@...nel.org>
Subject: Re: [PATCH v2] rust: pci: Allocate and manage PCI interrupt vectors
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!
Powered by blists - more mailing lists