Re: [PATCH 1/1] counter: intel-qep: Use devm_mutex_init()

From: Joshua Crofts

Date: Wed May 20 2026 - 08:02:30 EST


On Wed, 20 May 2026 at 13:25, Ilpo Järvinen
<ilpo.jarvinen@xxxxxxxxxxxxxxx> wrote:
>
> intel_qep_probe() calls mutex_init() but lacks the pairing
> mutex_destroy() calls. Convert to devm_mutex_init() which handles
> cleanup automatically.
>
> Fixes: b711f687a1c1 ("counter: Add support for Intel Quadrature Encoder Peripheral")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
> ---
> drivers/counter/intel-qep.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/counter/intel-qep.c b/drivers/counter/intel-qep.c
> index c49c178056f4..816586893517 100644
> --- a/drivers/counter/intel-qep.c
> +++ b/drivers/counter/intel-qep.c
> @@ -414,7 +414,9 @@ static int intel_qep_probe(struct pci_dev *pci, const struct pci_device_id *id)
>
> qep->dev = dev;
> qep->regs = regs;
> - mutex_init(&qep->lock);
> + ret = devm_mutex_init(dev, &qep->lock);
> + if (ret)
> + return ret;

Unless you're compiling with CONFIG_DEBUG_MUTEXES, mutex_destroy() is a
nop, so a solo mutex_init() call is okay. Nevertheless the devm_
counterpart makes
debugging easier.

Reviewed-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>

--
Kind regards

CJD