Re: [PATCH] iio: admv1013: initialize callback mutex before registering notifier
Jonathan Cameron <[email protected]>
| Newsgroups | org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <20260819014611.18db8689@jic23-huawei> |
On Tue, 18 Aug 2026 18:31:01 +0300 Andy Shevchenko <[email protected]> wrote: > On Tue, Aug 18, 2026 at 10:28:11PM +0800, Runyu Xiao wrote: > > admv1013_probe() registers a clock notifier whose callback takes > > st->lock on POST_RATE_CHANGE. Initialize the mutex before > > devm_clk_notifier_register() so the callback cannot observe an > > uninitialized lock during probe. > > ... > Move the (devm_)mutex_init() up here to keep the notifier setup all together after the change as it was before. > > st->nb.notifier_call = admv1013_freq_change; > > > + mutex_init(&st->lock); > > + > > Make it also to be devm_mutex_init(). Hmm. I'm a bit borderline on this as the minimal fix is indeed the move done here. I guess it is trivial to do the ret = devm_mutex_init(&st->lock); if (ret) return ret; so we might as well do that as part of the fix rather than adding churn by doing it as a follow up. So indeed, lets have that for v2. Thanks, Jonathan > > > ret = devm_clk_notifier_register(&spi->dev, st->clkin, &st->nb); > > if (ret) > > return ret; >