[PATCH v2 4/4] hwmon: chipcap2: serialize access to low/high_alarm indicators
From: Javier Carrasco
Date: Sun Aug 23 2026 - 14:00:37 EST
Access to low_alarm and high_alarm from the threaded interrupt handlers
and sysfs is not protected by any locking mechanism at the moment, which
can lead to missed events.
Use the hwmon subsystem lock to serialize access to the alarm indicators
and update their state before generating the corresponding event to keep
a consistent state.
Fixes: 3af350929e75 ("hwmon: Add support for Amphenol ChipCap 2")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>
---
drivers/hwmon/chipcap2.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/chipcap2.c b/drivers/hwmon/chipcap2.c
index 57d22d65612c..0a56c55e9394 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);
+ 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);
+ 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;
--
2.43.0