From: "Javier Carrasco" <javier.carrasco.cruz@gmail.com>
To: <sashiko-reviews@lists.linux.dev>,
"Javier Carrasco" <javier.carrasco.cruz@gmail.com>,
"Guenter Roeck" <linux@roeck-us.net>
Cc: <linux-hwmon@vger.kernel.org>
Subject: Re: [PATCH v2 4/4] hwmon: chipcap2: serialize access to low/high_alarm indicators
Date: Sun, 23 Aug 2026 20:16:25 +0200 [thread overview]
Message-ID: <DKWJ1VMYAVW6.21J53768947YI@gmail.com> (raw)
In-Reply-To: <20260823180616.1D53D1F000E9@smtp.kernel.org>
On Sun Aug 23, 2026 at 8:06 PM CEST, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] The `scoped_guard` macro is improperly terminated with a trailing semicolon, resulting in an empty critical section that leaves the alarm state updates unprotected.
> --
>
> --- Patch [4]: [PATCH v2 4/4] hwmon: chipcap2: serialize access to low/high_alarm indicators ---
> commit a0d28bd8208a1d69e597290c8ebb0fdf0731e68b
> Author: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>
> hwmon: chipcap2: serialize access to low/high_alarm indicators
>
> This commit attempts to serialize concurrent access to the hardware monitoring
> alarm indicators. It introduces scoped_guard usage within the threaded
> interrupt handlers to protect the low and high alarm state updates.
>
>> diff --git a/drivers/hwmon/chipcap2.c b/drivers/hwmon/chipcap2.c
>> index 57d22d65612c2..0a56c55e93942 100644
>> --- a/drivers/hwmon/chipcap2.c
>> +++ b/drivers/hwmon/chipcap2.c
> [ ... ]
>> @@ -495,9 +495,11 @@ static irqreturn_t cc2_low_interrupt(int irq, void *data)
>> struct cc2_data *cc2 = data;
>>
>> if (cc2->process_irqs) {
>> + scoped_guard(hwmon_lock, cc2->hwmon);
>
> [Severity: High]
> Does this trailing semicolon create an empty critical section?
>
> Because scoped_guard expands to a for loop, placing a semicolon immediately
> after it makes the loop body empty. This means the lock is acquired and
> immediately released.
>
> The subsequent assignment to cc2->rh_alarm.low_alarm executes entirely outside
> the lock, leaving the data race unmitigated. Should the assignment be wrapped
> in a compound block without the trailing semicolon?
>
This feedback is correct. The trailing semicolon is for guard() and not
scoped_guard(). I will fix that for V3.
>> + cc2->rh_alarm.low_alarm = true;
>> +
>> hwmon_notify_event(cc2->hwmon, hwmon_humidity,
>> hwmon_humidity_min_alarm, 0);
>> - cc2->rh_alarm.low_alarm = true;
>> }
>>
>> return IRQ_HANDLED;
>> @@ -508,9 +510,11 @@ static irqreturn_t cc2_high_interrupt(int irq, void *data)
>> struct cc2_data *cc2 = data;
>>
>> if (cc2->process_irqs) {
>> + scoped_guard(hwmon_lock, cc2->hwmon);
>
> [Severity: High]
> Does the same empty critical section issue apply here for the high_alarm
> update?
>
Same here.
>> + cc2->rh_alarm.high_alarm = true;
>> +
>> hwmon_notify_event(cc2->hwmon, hwmon_humidity,
>> hwmon_humidity_max_alarm, 0);
>> - cc2->rh_alarm.high_alarm = true;
>> }
>>
>> return IRQ_HANDLED;
Best regards,
Javier
prev parent reply other threads:[~2026-08-23 18:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 17:59 [PATCH v2 0/4] hwmon: chipcap2: various bug fixes Javier Carrasco
2026-08-23 17:59 ` [PATCH v2 1/4] hwmon: chipcap2: fix channels in humidity alarm notifications Javier Carrasco
2026-08-23 18:11 ` sashiko-bot
2026-08-23 18:17 ` Javier Carrasco
2026-08-23 17:59 ` [PATCH v2 2/4] hwmon: chipcap2: fix IRQ teardown ordering Javier Carrasco
2026-08-23 18:12 ` sashiko-bot
2026-08-23 18:22 ` Javier Carrasco
2026-08-23 21:14 ` Javier Carrasco
2026-08-23 17:59 ` [PATCH v2 3/4] hwmon: chipcap2: enable IRQ processing when regulator is already enabled Javier Carrasco
2026-08-23 18:11 ` sashiko-bot
2026-08-23 19:13 ` Javier Carrasco
2026-08-23 17:59 ` [PATCH v2 4/4] hwmon: chipcap2: serialize access to low/high_alarm indicators Javier Carrasco
2026-08-23 18:06 ` sashiko-bot
2026-08-23 18:16 ` Javier Carrasco [this message]
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=DKWJ1VMYAVW6.21J53768947YI@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=sashiko-reviews@lists.linux.dev \
/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