From: sashiko-bot@kernel.org
To: "Rodrigo Alencar via B4 Relay"
<devnull+rodrigo.alencar.analog.com@kernel.org>
Cc: krzk+dt@kernel.org, devicetree@vger.kernel.org,
conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH RFC v4 08/10] iio: frequency: ad9910: show channel priority in debugfs
Date: Sat, 09 May 2026 01:49:07 +0000 [thread overview]
Message-ID: <20260509014908.4616CC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508-ad9910-iio-driver-v4-8-d26bfd20ee3d@analog.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [Critical] Missing `.open` callback in debugfs `file_operations` leads to a guaranteed NULL pointer dereference.
- [High] Function prototype mismatch in `file_operations` `.read` callbacks causes build failures and CFI panics.
- [Medium] Register bitmasks are applied to the wrong control registers, leading to corrupted state evaluation.
- [Low] Using `simple_read_from_buffer` with dynamically evaluated string pointers creates a TOCTOU race condition.
- [Low] The strings exposed through debugfs lack a trailing newline.
--
commit f3ad86f1b54a4f67b1e1ded4fa3bd327c17e7ba9
Author: Rodrigo Alencar <rodrigo.alencar@analog.com>
iio: frequency: ad9910: show channel priority in debugfs
Expose frequency_source, phase_source and amplitude_source attributes in
debugfs to indicate which channel the specific DDS parameter is being sourced
from.
> diff --git a/drivers/iio/frequency/ad9910.c b/drivers/iio/frequency/ad9910.c
> index 1fdbaba356d73..d8fe88259f22d 100644
> --- a/drivers/iio/frequency/ad9910.c
> +++ b/drivers/iio/frequency/ad9910.c
> @@ -2082,6 +2082,170 @@ static int ad9910_setup(struct device *dev, struct ad9910_state *st,
[ ... ]
> + /* Parallel data port enabled and data destination is frequency */
> + mode_en = FIELD_GET(AD9910_CFR2_PARALLEL_DATA_PORT_EN_MSK,
> + st->reg[AD9910_REG_CFR1].val32);
Does this apply a CFR2 mask to a CFR1 register? It seems
AD9910_CFR2_PARALLEL_DATA_PORT_EN_MSK should be evaluated against
st->reg[AD9910_REG_CFR2].
> + if (mode_en) /* TODO: get destination from backend once it is supported */
> + return ad9910_channel_str[AD9910_CHAN_IDX_PARALLEL_PORT];
[ ... ]
> +static int ad9910_frequency_source_show(struct file *file, char __user *userbuf,
> + size_t count, loff_t *ppos)
Does the .read callback in struct file_operations require a return type of
ssize_t instead of int? Could this mismatch cause build failures or
Control Flow Integrity (CFI) kernel panics?
> +{
> + struct iio_dev *indio_dev = file->private_data;
Without an .open handler like simple_open(), the VFS and debugfs proxy
layers leave file->private_data initialized to NULL. Does this lead to a NULL
pointer dereference when iio_priv() extracts the state from indio_dev?
> + const char *src = ad9910_frequency_source_get(indio_dev);
Do the static strings returned here lack a trailing newline (\n)? Reading
this file might overwrite or corrupt the user's shell prompt.
> +
> + return simple_read_from_buffer(userbuf, count, ppos, src, strlen(src));
If userspace performs a partial read and the hardware state changes before
the next read(), could ad9910_frequency_source_get() return a different,
shorter string?
If this occurs, simple_read_from_buffer() would apply the old *ppos to the
new string, potentially returning garbage. Would using seq_file
via DEFINE_SHOW_ATTRIBUTE() safely cache the output buffer upon open()?
> +}
> +
> +static inline const char *ad9910_phase_source_get(struct iio_dev *indio_dev)
> +{
[ ... ]
> + /* Parallel data port enabled and data destination is phase */
> + mode_en = FIELD_GET(AD9910_CFR2_PARALLEL_DATA_PORT_EN_MSK,
> + st->reg[AD9910_REG_CFR1].val32);
Is this another case where a CFR2 mask is applied to a CFR1 register?
> + if (mode_en) /* TODO: get destination from backend once it is supported */
> + return ad9910_channel_str[AD9910_CHAN_IDX_PARALLEL_PORT];
[ ... ]
> +static int ad9910_phase_source_show(struct file *file, char __user *userbuf,
> + size_t count, loff_t *ppos)
Could this return type also be ssize_t instead of int to match the .read
callback signature?
> +{
> + struct iio_dev *indio_dev = file->private_data;
Does this have the same NULL pointer dereference issue as the frequency show
function due to missing simple_open()?
> + const char *src = ad9910_phase_source_get(indio_dev);
> +
> + return simple_read_from_buffer(userbuf, count, ppos, src, strlen(src));
> +}
> +
> +static inline const char *ad9910_amplitude_source_get(struct iio_dev *indio_dev)
> +{
> + struct ad9910_state *st = iio_priv(indio_dev);
> + bool ram_en, mode_en;
> + u32 destination;
> +
> + guard(mutex)(&st->lock);
> +
> + /* OSK enabled */
> + mode_en = FIELD_GET(AD9910_CFR1_OSK_ENABLE_MSK,
> + st->reg[AD9910_REG_CFR2].val32);
Does this apply a CFR1 mask to a CFR2 register?
> + if (mode_en)
> + return ad9910_channel_str[AD9910_CHAN_IDX_OSK];
> +
[ ... ]
> + /* Parallel data port enabled and data destination is phase */
> + mode_en = FIELD_GET(AD9910_CFR2_PARALLEL_DATA_PORT_EN_MSK,
> + st->reg[AD9910_REG_CFR1].val32);
Is this a third instance of applying a CFR2 mask to a CFR1 register?
> + if (mode_en) /* TODO: get destination from backend once it is supported */
> + return ad9910_channel_str[AD9910_CHAN_IDX_PARALLEL_PORT];
[ ... ]
> +static int ad9910_amplitude_source_show(struct file *file, char __user *userbuf,
> + size_t count, loff_t *ppos)
Could this return type also be ssize_t instead of int?
> +{
> + struct iio_dev *indio_dev = file->private_data;
Does this have the same NULL pointer dereference issue as the other show
functions?
> + const char *src = ad9910_amplitude_source_get(indio_dev);
> +
> + return simple_read_from_buffer(userbuf, count, ppos, src, strlen(src));
> +}
> +
> +static const struct file_operations ad9910_frequency_source_fops = {
> + .owner = THIS_MODULE,
> + .read = ad9910_frequency_source_show,
> +};
Should this struct include an .open callback, such as simple_open(), to ensure
that file->private_data is initialized correctly before .read is called?
> +
> +static const struct file_operations ad9910_phase_source_fops = {
> + .owner = THIS_MODULE,
> + .read = ad9910_phase_source_show,
> +};
> +
> +static const struct file_operations ad9910_amplitude_source_fops = {
> + .owner = THIS_MODULE,
> + .read = ad9910_amplitude_source_show,
> +};
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508-ad9910-iio-driver-v4-0-d26bfd20ee3d@analog.com?part=8
next prev parent reply other threads:[~2026-05-09 1:49 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 17:00 [PATCH RFC v4 00/10] AD9910 Direct Digital Synthesizer Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-08 17:00 ` [PATCH RFC v4 01/10] dt-bindings: iio: frequency: add ad9910 Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-08 22:02 ` sashiko-bot
2026-05-12 18:31 ` Jonathan Cameron
2026-05-13 15:09 ` Rodrigo Alencar
2026-05-16 10:40 ` Jonathan Cameron
2026-05-08 17:00 ` [PATCH RFC v4 02/10] iio: core: support 64-bit register through debugfs Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-08 22:20 ` sashiko-bot
2026-05-10 10:07 ` Andy Shevchenko
2026-05-11 10:47 ` Rodrigo Alencar
2026-05-08 17:00 ` [PATCH RFC v4 03/10] iio: frequency: ad9910: initial driver implementation Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-08 22:51 ` sashiko-bot
2026-05-08 17:00 ` [PATCH RFC v4 04/10] iio: frequency: ad9910: add basic parallel port support Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-08 23:19 ` sashiko-bot
2026-05-08 17:00 ` [PATCH RFC v4 05/10] iio: frequency: ad9910: add digital ramp generator support Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-08 23:53 ` sashiko-bot
2026-05-08 17:00 ` [PATCH RFC v4 06/10] iio: frequency: ad9910: add RAM mode support Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-09 0:33 ` sashiko-bot
2026-05-08 17:00 ` [PATCH RFC v4 07/10] iio: frequency: ad9910: add output shift keying support Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-09 1:08 ` sashiko-bot
2026-05-08 17:00 ` [PATCH RFC v4 08/10] iio: frequency: ad9910: show channel priority in debugfs Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-09 1:49 ` sashiko-bot [this message]
2026-05-08 17:00 ` [PATCH RFC v4 09/10] Documentation: ABI: testing: add docs for ad9910 sysfs entries Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-09 1:24 ` sashiko-bot
2026-05-08 17:00 ` [PATCH RFC v4 10/10] docs: iio: add documentation for ad9910 driver Rodrigo Alencar
2026-05-08 17:00 ` Rodrigo Alencar via B4 Relay
2026-05-09 1:21 ` sashiko-bot
2026-05-09 23:42 ` David Lechner
2026-05-10 9:30 ` Rodrigo Alencar
2026-05-11 14:46 ` David Lechner
2026-05-11 15:02 ` Rodrigo Alencar
2026-05-11 15:23 ` David Lechner
2026-05-11 16:01 ` Rodrigo Alencar
2026-05-15 15:47 ` Rodrigo Alencar
2026-05-09 22:31 ` [PATCH RFC v4 00/10] AD9910 Direct Digital Synthesizer David Lechner
2026-05-10 8:50 ` Rodrigo Alencar
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=20260509014908.4616CC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+rodrigo.alencar.analog.com@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=robh@kernel.org \
--cc=sashiko@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.