From: Mark Brown <broonie@kernel.org>
To: Pei Xiao <xiaopei01@kylinos.cn>
Cc: cl634@andestech.com, linux-spi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] spi: atcspi200: fix mutex initialization order
Date: Thu, 12 Mar 2026 11:22:13 +0000 [thread overview]
Message-ID: <8313fa0b-9c15-41da-aff6-4228a2b1f03e@sirena.org.uk> (raw)
In-Reply-To: <c95608b9-4912-4b42-a188-1265d603ddb0@kylinos.cn>
[-- Attachment #1: Type: text/plain, Size: 988 bytes --]
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-03-12 11:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 1:55 [PATCH v2 0/2] two cleanups in atcspi200 Pei Xiao
2026-03-11 1:55 ` [PATCH v2 1/2] spi: atcspi200: Use helper function devm_clk_get_enabled() Pei Xiao
2026-03-11 1:55 ` [PATCH v2 2/2] spi: atcspi200: fix mutex initialization order Pei Xiao
2026-03-11 12:29 ` Mark Brown
2026-03-12 2:25 ` Pei Xiao
2026-03-12 11:22 ` Mark Brown [this message]
2026-03-11 18:57 ` (subset) [PATCH v2 0/2] two cleanups in atcspi200 Mark Brown
2026-03-14 21:58 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8313fa0b-9c15-41da-aff6-4228a2b1f03e@sirena.org.uk \
--to=broonie@kernel.org \
--cc=cl634@andestech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=xiaopei01@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®