From: sashiko-bot@kernel.org
To: "Jorijn van der Graaf" <jorijnvdgraaf@catcrafts.net>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 4/5] iio: light: stk3310: add per-chip match data
Date: Wed, 26 Aug 2026 18:03:37 +0000 [thread overview]
Message-ID: <20260826180337.738421F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260826175409.326131-5-jorijnvdgraaf@catcrafts.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] stk3310_write_event() modifies hardware registers and shared cached state without holding the driver lock, leading to state desynchronization.
--
commit 1a4ec350350bbed28440d2daf132d19b8c5712c9
Author: Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>
iio: light: stk3310: add per-chip match data
Introduce a chip_info structure carrying the device name and channel
specification, attach it to every i2c, OF and ACPI table entry, and
let probe take it from the match data, failing when there is none.
> diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
> index 156888969366c..d632e6447f065 100644
> --- a/drivers/iio/light/stk3310.c
> +++ b/drivers/iio/light/stk3310.c
[Severity: High]
This is a pre-existing issue, but does stk3310_write_event() need to hold
data->lock to prevent concurrent access?
Looking at stk3310_write_event(), it modifies hardware registers and shared
cached state without holding the driver lock:
ret = regmap_bulk_write(data->regmap, reg, &buf, sizeof(buf));
if (ret < 0) {
dev_err(&client->dev, "failed to set PS threshold!\n");
return ret;
}
if (reg == STK3310_REG_THDH_PS)
data->ps_thdh = val;
else
data->ps_thdl = val;
This allows a race between concurrent writers to cause a state
desynchronization between the hardware registers and the driver's cached
threshold values (data->ps_thdh and data->ps_thdl).
On system resume, the driver restores these incorrect cached thresholds to the
hardware, resulting in incorrect proximity event behavior.
Additionally, this function reads state that could concurrently be modified by
stk3310_write_raw() without a lock:
ret = regmap_field_read(data->reg_ps_gain, &index);
This causes a TOCTOU race on threshold bounds checking.
Could we add a mutex_lock() to stk3310_write_event() to synchronize with
stk3310_write_raw() and prevent state desynchronization?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826175409.326131-1-jorijnvdgraaf@catcrafts.net?part=4
next prev parent reply other threads:[~2026-08-26 18:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 17:54 [PATCH v2 0/5] iio: light: stk3310: per-chip match data and STK36C61 support Jorijn van der Graaf
2026-08-26 17:54 ` [PATCH v2 1/5] iio: light: stk3310: lower-case the i2c device ID names Jorijn van der Graaf
2026-08-26 18:03 ` sashiko-bot
2026-08-27 6:45 ` Andy Shevchenko
2026-08-26 17:54 ` [PATCH v2 2/5] dt-bindings: iio: light: stk33xx: document the Sensortek STK36C61 Jorijn van der Graaf
2026-08-26 17:54 ` [PATCH v2 3/5] iio: light: stk3310: move the data registers into the channel address Jorijn van der Graaf
2026-08-26 18:07 ` sashiko-bot
2026-08-27 6:47 ` Andy Shevchenko
2026-08-26 17:54 ` [PATCH v2 4/5] iio: light: stk3310: add per-chip match data Jorijn van der Graaf
2026-08-26 18:03 ` sashiko-bot [this message]
2026-08-27 7:47 ` Andy Shevchenko
2026-08-26 17:54 ` [PATCH v2 5/5] iio: light: stk3310: support the Sensortek STK36C61 Jorijn van der Graaf
2026-08-27 7:53 ` Andy Shevchenko
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=20260826180337.738421F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jorijnvdgraaf@catcrafts.net \
--cc=robh@kernel.org \
--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