Re: [PATCH v2 2/2] spi: atcspi200: fix mutex initialization order
From: Mark Brown
Date: Thu Mar 12 2026 - 07:22:23 EST
On Thu, Mar 12, 2026 at 10:25:11AM +0800, Pei Xiao wrote:
> 在 2026/3/11 20:29, Mark Brown 写道:
> > On Wed, Mar 11, 2026 at 09:55:14AM +0800, Pei Xiao wrote:
> >> + ret = devm_mutex_init(spi->dev, &spi->mutex_lock);
> >> + if (ret)
> >> + goto free_controller;
> >> +
> > This means we're now using devm to free the mutex that is in spi, but
> > when we pass spi into devm_spi_register_controller() we'll cause spi to
> > be freed before we free the mutex. This pattern gets a bit clunky with
> > devm...
> Thanks for review! I will use mutex_init() for V3 version.
That's still going to have trouble because if you do the free in the
removal function the lock will go away before the controller which is
it's own issue (this is what I mean about clunky). It's especially
annoying as it's only an issue for debugging builds. I can't actually
see a good way of dealing with this, perhaps just a plain mutex_init()
without a free is the least bad option.
Attachment:
signature.asc
Description: PGP signature