From: sashiko-bot@kernel.org
To: "Paweł Wiśniewski" <pawel.wis.me@gmail.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [RFC PATCH 3/3] iio: proximity: srf04: Add Cytron HC-SR04 support
Date: Thu, 16 Jul 2026 17:46:19 +0000 [thread overview]
Message-ID: <20260716174620.56F941F000E9@smtp.kernel.org> (raw)
In-Reply-To: <3fedc827a2581d61bef9ea639ed77cf90e80047a.1784221074.git.pawel.wis.me@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Unchecked return value from `device_get_match_data()` can cause a NULL pointer dereference.
- [High] Interrupt handler may miss the rising edge of the echo pulse due to interrupt latency.
--
--- Patch [3]: [RFC PATCH 3/3] iio: proximity: srf04: Add Cytron HC-SR04 support ---
commit e27499a683a294e308b2d89b6fa06d4fd87a1cef
Author: Paweł Wiśniewski <pawel.wis.me@gmail.com>
iio: proximity: srf04: Add Cytron HC-SR04 support
This commit adds support for the Cytron HC-SR04 sensor to the srf04 driver.
It introduces the new compatible string "cytron,hc-sr04" and updates the
Kconfig to list the supported device.
> diff --git a/drivers/iio/proximity/srf04.c b/drivers/iio/proximity/srf04.c
> index 7be50bdebfcbc..f5ee7d6572b5b 100644
> --- a/drivers/iio/proximity/srf04.c
> +++ b/drivers/iio/proximity/srf04.c
[ ... ]
> @@ -231,6 +231,7 @@ static const struct iio_chan_spec srf04_chan_spec[] = {
> };
>
> static const struct of_device_id of_srf04_match[] = {
> + { .compatible = "cytron,hc-sr04", .data = &srf04_cfg },
[Severity: High]
This is a pre-existing issue, and was not introduced by the patch under
review, but could the unchecked return value from device_get_match_data()
cause a NULL pointer dereference?
In drivers/iio/proximity/srf04.c:srf04_probe(), the return value is assigned
without validation:
data->cfg = device_get_match_data(dev);
If the driver is instantiated via legacy platform device registration,
device_get_match_data() will return NULL. Later, in srf04_read(), this could
be dereferenced:
udelay(data->cfg->trigger_pulse_us);
Can this result in a kernel panic when a user reads from the IIO device?
[Severity: High]
This is a pre-existing issue, and was not introduced by the patch under
review, but could the interrupt handler miss the rising edge of the echo
pulse due to interrupt latency?
In drivers/iio/proximity/srf04.c:srf04_handle_irq(), the handler relies on
the live GPIO state:
if (gpiod_get_value(data->gpiod_echo)) {
If an object is close, the echo pulse is very short. If the system's
interrupt latency exceeds this duration, the GPIO will already have
transitioned back to low by the time the handler executes for the rising
edge. The handler will read low, complete the falling completion, and
ignore the rising edge.
This would cause the read operation to time out and fail in srf04_read():
ret = wait_for_completion_killable_timeout(&data->rising, HZ/50);
Could this cause the sensor to consistently fail to measure short distances
and return -ETIMEDOUT to userspace?
> { .compatible = "devantech,srf04", .data = &srf04_cfg },
> { .compatible = "maxbotix,mb1000", .data = &mb_lv_cfg },
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784221074.git.pawel.wis.me@gmail.com?part=3
next prev parent reply other threads:[~2026-07-16 17:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 17:35 [RFC PATCH 0/3] iio: proximity: Add Cytron HC-SR04 support Paweł Wiśniewski
2026-07-16 17:35 ` [RFC PATCH 1/3] dt-bindings: vendor-prefixes: Add Cytron Technologies Paweł Wiśniewski
2026-07-16 17:35 ` [RFC PATCH 2/3] dt-bindings: iio: proximity: Add Cytron HC-SR04 Paweł Wiśniewski
2026-07-16 17:45 ` sashiko-bot
2026-07-16 17:35 ` [RFC PATCH 3/3] iio: proximity: srf04: Add Cytron HC-SR04 support Paweł Wiśniewski
2026-07-16 17:46 ` sashiko-bot [this message]
2026-07-16 18:22 ` [RFC PATCH 0/3] iio: proximity: " 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=20260716174620.56F941F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=pawel.wis.me@gmail.com \
--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