On Tue, 15 Sep 2026 08:46:01 -0300
Jason Gunthorpe [off-list ref] wrote:
On Tue, Sep 15, 2026 at 02:52:14PM +0530, Aneesh Kumar K.V wrote:
quoted
quoted
Yes, but as written it is OK, and this is a common pattern in the
kernel. I agree it is fragile tricky..
Still it isn't an urgent reason to change it around, but the best
pattern is to put the allocate, dev.release=, and device_initialize()
in one 'alloc' function. Then the other function calls it and always
unwinds with put_device. Use device_add().
This avoids mixing the different kfree/put_device error unwind regimes
into the same function..
Something like
Yeah, this is the safest way I know to use these interfaces
Agreed.
Jason