From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Runyu Xiao <runyu.xiao@seu.edu.cn>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>,
Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
Kris Huang <huang_kris@projectara.com>,
greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: greybus: light: initialize channel lock before registration
Date: Wed, 19 Aug 2026 15:29:11 +0200 [thread overview]
Message-ID: <2026081944-divisible-trodden-ab4b@gregkh> (raw)
In-Reply-To: <20260819132108.17767-1-runyu.xiao@seu.edu.cn>
On Wed, Aug 19, 2026 at 09:21:08PM +0800, Runyu Xiao wrote:
> You're right, and "tested" was the wrong word in my reply.
Sorry, I have no context :(
Remember, some of us get thousands of emails a day.
> The finding here is from code inspection, not from a runtime test. The
> path I checked is:
>
> gb_lights_channel_register()
> -> led_classdev_register()
> publishes cdev->brightness_set_blocking
> (= gb_brightness_set()
> -> __gb_lights_brightness_set()
> -> __gb_lights_led_brightness_set()
> -> mutex_lock(&channel->lock))
>
> but mutex_init(&channel->lock) only runs after
> gb_lights_channel_register() returns, and that is the only place where
> channel->lock is initialized. So the lock is published before it is
> initialized.
>
> The QEMU module I mentioned does not exercise this driver. It only shows
> that taking an uninitialized mutex triggers the expected
> DEBUG_LOCKS_WARN_ON(lock->magic != lock), so I should not have described
> it as driver testing or as a reproducer for this driver.
>
> And yes, 6.1.66 was only the kernel version in that local QEMU setup. The
> patch itself was made and compile-checked against current mainline, and
> I'll keep validation against mainline for future submissions.
Just build testing against a many-year-old kernel is a sure way to
ensure that nothing will actually work at all :(
> The initial report came from PatchProof, a static-analysis pipeline I am
> building for lock-API misuse. It flagged this publish-before-init ordering,
> and I then manually verified the call path above. I did use an LLM as an
> assistant during the workflow, but the finding itself was from the checker
> and the patch I sent was based on my manual review of the code.
Please read the archives for why we don't take LLM patches for
drivers/staging/ unless you can test the change on real hardware.
thanks,
greg k-h
next prev parent reply other threads:[~2026-08-19 13:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 14:20 [PATCH] staging: greybus: light: initialize channel lock before registration Runyu Xiao
2026-08-18 18:23 ` Greg Kroah-Hartman
[not found] ` <ANAASQBEK9Ye2X-O4oze*arv.3.1787142765226.Hmail.220255722@seu.edu.cn>
2026-08-19 12:40 ` Greg Kroah-Hartman
2026-08-19 12:41 ` Greg Kroah-Hartman
2026-08-19 13:21 ` Runyu Xiao
2026-08-19 13:29 ` Greg Kroah-Hartman [this message]
2026-08-19 13:39 ` Runyu Xiao
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=2026081944-divisible-trodden-ab4b@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=elder@kernel.org \
--cc=greybus-dev@lists.linaro.org \
--cc=huang_kris@projectara.com \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=rmfrfs@gmail.com \
--cc=runyu.xiao@seu.edu.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