Re: [PATCH v2] counter: ftm-quaddec: use devm_mutex_init()
From: William Breathitt Gray
Date: Thu May 28 2026 - 22:09:14 EST
On Thu, May 28, 2026 at 02:07:45PM +0100, Jonathan Cameron wrote:
> On Thu, 28 May 2026 06:52:18 +0900
> William Breathitt Gray <wbg@xxxxxxxxxx> wrote:
>
> > On Wed, May 27, 2026 at 05:57:58PM +0100, Jonathan Cameron wrote:
> > > On Tue, 26 May 2026 12:24:25 +0200
> > > Joshua Crofts <joshua.crofts1@xxxxxxxxx> wrote:
> > >
> > > > On Mon, 25 May 2026 at 17:14, Stepan Ionichev <sozdayvek@xxxxxxxxx> wrote:
> > > > >
> > > > > ftm_quaddec_probe() calls mutex_init() but neither the cleanup
> > > > > action nor a remove callback issues a matching mutex_destroy(),
> > > > > which leaks the lock debug state when CONFIG_DEBUG_MUTEXES is
> > > > > enabled.
> > > > >
> > > > > Switch to devm_mutex_init() so the mutex is torn down in the same
> > > > > devm scope it was set up in.
> > > > >
> > > > > Fixes: a3b9a99980d9 ("counter: add FlexTimer Module Quadrature decoder counter driver")
> > > > > Signed-off-by: Stepan Ionichev <sozdayvek@xxxxxxxxx>
> > > > > ---
> > > > > v2:
> > > > > - Add Fixes tag and note that the leak only shows up under
> > >
> > > It's not a leak as such. All that happens is the 'magic' pointer embedded
> > > in the lock is not set NULL. No memory or counters or anything like that leaked
> > > in current mainline where the implementation with CONFIG_DEBUG_MUTEXES is
> > >
> > > void mutex_destroy(struct mutex *lock)
> > > {
> > > DEBUG_LOCKS_WARN_ON(mutex_is_locked(lock));
> > > lock->magic = NULL;
> > > }
> >
> > What is the purpose of the magic pointer? Is it just informational, to
> > catch instances where any attempt to use the mutex occurs after the
> > device memory is freed for example?
> More or less. In some cases the mutex life can be less than the structure
> containing it.
Stepan,
I think Jonathan is right, so I'm going to drop the Fixes tag for this
one, and pick up as well the original revision of your interrupt-cnt
patch without the Fixes tag. Sorry for the noise.
Thank you,
William Breathitt Gray