Re: [PATCH] gpio: sysfs: add missing mutex_destroy()
From: Bartosz Golaszewski
Date: Mon May 19 2025 - 08:19:40 EST
On Fri, May 16, 2025 at 6:58 PM Johan Hovold <johan@xxxxxxxxxx> wrote:
>
> On Fri, May 16, 2025 at 02:32:54PM +0200, Bartosz Golaszewski wrote:
> > On Fri, May 16, 2025 at 1:42 PM Johan Hovold <johan@xxxxxxxxxx> wrote:
> > >
> > > On Fri, May 16, 2025 at 12:40:23PM +0200, Bartosz Golaszewski wrote:
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> > > >
> > > > We initialize the data->mutex in gpiod_export() but lack the
> > > > corresponding mutex_destroy() in gpiod_unexport() causing a resource
> > > > leak with mutex debugging enabled. Add the call right before kfreeing
> > > > the GPIO data.
> > >
> > > No, there's no resource leak and it's perfectly fine not to call
> > > mutex_destroy().
> >
> > No, there's no leak but with lock debugging it still warns if the
> > mutex is locked when it's being destroyed so the change still makes
> > sense with a modified commit message.
> >
> > > You can't just make shit up and then pretend to fix it...
> >
> > There's no need for this kind of comment. You made your point clear in
> > the first sentence.
>
> Your claim that there's "a resource leak with mutex debugging enabled"
> is is quite specific. Now I had to go check that no one had changed
> something in ways they shouldn't have recently. But mutex_destroy()
> still works as it always has, which you should have verified yourself
> before sending a "fix" tagged for stable backport based on a hunch.
>
Yes, I admitted that the commit message was wrong. And yes, it
sometimes happens that we get copied on crappy patches. However,
unlike what your comment suggests, I don't go around the kernel,
"making sh*t up" just to add a "Fixes: Johan's commit". I had this as
part of a bigger rework I have in progress[1] (discussed previously
here[2]) and figured that with the series growing in size, I'll at
least get the fix upstream before v6.16-rc1.
I should have given the patch more than 10 seconds of thought for sure
but your immediate hostility is uncalled for. Please try to assume
good faith a bit more.
Bartosz
[1] https://github.com/brgl/linux/tree/b4/gpio-sysfs-chip-export
[2] https://lore.kernel.org/all/CAMRc=McUCeZcU6co1aN54rTudo+JfPjjForu4iKQ5npwXk6GXA@xxxxxxxxxxxxxx/