Simple mutex_destroy question

Greg KH greg at kroah.com
Thu Nov 20 08:43:58 EST 2025


On Thu, Nov 20, 2025 at 10:27:06AM +0000, Lucas Tanure wrote:
> On Wed, Nov 19, 2025 at 4:27 PM Billie Alsup (balsup) <balsup at cisco.com> wrote:
> >
> > Since you're using devm_kzalloc, why not simply use devm_mutex_init and not worry about it?  Then you can remove your explicit mutex_destroy call.
> 
> I am developing drivers for Android 13 with kernel 5.10/5.4, which
> doesn't have devm_mutex_init.

No new devices should be shipping with Android13 as it is about to go
end-of-life, so please do NOT target these old kernels.

Do your development on the latest kernel release, get your changes
upstream, and then, if you need to apply them to a device-specific
kernel, backport it to that older kernel.  That way is much simpler and
easier and will save you time.

> So, mutex_destroy is only needed for debugging locks? I see a few
> drivers don't have this call in their remove functions or in fail
> probe paths.

Then those are probably bugs that should be fixed up.

thanks,

greg k-h



More information about the Kernelnewbies mailing list