Re: [PATCH v3 2/2] kunit: avoid memory leak on device register error
From: Greg Kroah-Hartman
Date: Fri Apr 19 2024 - 09:59:56 EST
On Fri, Apr 19, 2024 at 09:30:06AM -0300, Wander Lairson Costa wrote:
> As a side note, the behavior of device_register() seems
> counterintuitive and error-prone, IMO. If the function returns an
> error, it should ensure it leaks no resource and shouldn't require the
> caller to do any cleanup.
I too want a pony, but that's not the way the code works here, sorry.
It's always been like this, and has always been a problem, but last time
I looked, there was no way to really fix this. That's why we document
it a lot to make sure people don't get the error paths wrong here. I
know it's a pain :(
sorry,
greg k-h