From: sashiko-bot@kernel.org
To: "Stefan Popa" <stefan.popa@analog.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 2/2] iio: adc: add MAX40080 current-sense amplifier driver
Date: Mon, 13 Jul 2026 12:17:40 +0000 [thread overview]
Message-ID: <20260713121741.02CD21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713120226.90303-3-stefan.popa@analog.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing `dev_set_drvdata()` in `max40080_probe()` causes a NULL/garbage pointer dereference in `max40080_resume()`.
- [Medium] Missing bounds check on hardware register read causes out-of-bounds array access in `max40080_get_oversampling_ratio()`.
--
--- Patch [2]: [PATCH v2 2/2] iio: adc: add MAX40080 current-sense amplifier driver ---
commit 0eea8e710f553ebc05e51c736e312f8a7ed070f6
Author: Stefan Popa <stefan.popa@analog.com>
Subject: iio: adc: add MAX40080 current-sense amplifier driver
This commit adds a direct-mode IIO driver for the MAX40080 bidirectional
current-sense amplifier. It exposes current and voltage channels, handles
selectable input ranges, and features PEC-protected register access.
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX40080.pdf
> diff --git a/drivers/iio/adc/max40080.c b/drivers/iio/adc/max40080.c
> new file mode 100644
> index 0000000000000..87d2665151eda
> --- /dev/null
> +++ b/drivers/iio/adc/max40080.c
[ ... ]
> +static int max40080_get_oversampling_ratio(struct max40080_state *st, int *val)
> +{
> + int tmp;
> + u8 filter;
> +
> + tmp = i2c_smbus_read_word_data(st->client, MAX40080_REG_CFG);
> + if (tmp < 0)
> + return tmp;
> +
> + filter = FIELD_GET(MAX40080_CFG_FILTER_MSK, tmp);
> + *val = max40080_oversampling_avail[filter];
[Severity: Medium]
Can filter exceed the bounds of the max40080_oversampling_avail array?
MAX40080_CFG_FILTER_MSK is GENMASK(14, 12), which allows values from 0 to 7.
However, the max40080_oversampling_avail array only has 6 elements.
If the device hardware enters an unexpected state or returns bits 6 or 7,
will this read past the end of the array and potentially leak kernel memory
to userspace?
> +
> + return 0;
> +}
[ ... ]
> +static int max40080_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> + struct max40080_state *st = iio_priv(indio_dev);
> +
> + /*
> + * A suspend may have cut power to the device, resetting it to its
> + * power-on defaults. Reprogram it from the cached configuration.
> + */
> + guard(mutex)(&st->lock);
[Severity: High]
Does max40080_probe() need to call dev_set_drvdata() before returning?
If the system suspends and resumes, max40080_resume() calls
dev_get_drvdata(dev) expecting an iio_dev pointer. But since max40080_probe()
doesn't set it, will this return the I2C core default (the i2c_client pointer)
instead?
If so, casting it to struct iio_dev * and calling iio_priv() will return a
garbage pointer for st, causing a crash when the lock is accessed here.
> +
> + return max40080_init(st);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260713120226.90303-1-stefan.popa@analog.com?part=2
next prev parent reply other threads:[~2026-07-13 12:17 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:29 [PATCH v1 0/2] iio: adc: add MAX40080 current-sense amplifier driver Stefan Popa
2026-07-03 10:29 ` [PATCH v1 1/2] dt-bindings: iio: adc: add maxim,max40080 Stefan Popa
2026-07-03 16:21 ` Conor Dooley
2026-07-03 20:42 ` David Lechner
2026-07-03 10:29 ` [PATCH v1 2/2] iio: adc: add MAX40080 current-sense amplifier driver Stefan Popa
2026-07-03 10:42 ` sashiko-bot
2026-07-03 12:08 ` Andy Shevchenko
2026-07-03 23:36 ` Jonathan Cameron
2026-07-03 19:42 ` Siratul Islam
2026-07-03 20:29 ` David Lechner
2026-07-04 12:05 ` Andy Shevchenko
2026-07-04 16:32 ` Siratul Islam
2026-07-04 17:05 ` Andy Shevchenko
2026-07-04 17:30 ` Siratul Islam
2026-07-04 18:52 ` Andy Shevchenko
2026-07-03 21:04 ` David Lechner
2026-07-03 23:53 ` Jonathan Cameron
2026-07-06 17:17 ` Uwe Kleine-König
2026-07-03 11:34 ` [PATCH v1 0/2] " Andy Shevchenko
2026-07-13 12:02 ` [PATCH v2 " Stefan Popa
2026-07-13 12:02 ` [PATCH v2 1/2] dt-bindings: iio: adc: add maxim,max40080 Stefan Popa
2026-07-13 16:06 ` Conor Dooley
2026-07-13 12:02 ` [PATCH v2 2/2] iio: adc: add MAX40080 current-sense amplifier driver Stefan Popa
2026-07-13 12:17 ` sashiko-bot [this message]
2026-07-13 16:04 ` Andy Shevchenko
2026-07-13 12:16 ` [PATCH v2 0/2] " Joshua Crofts
2026-07-14 12:24 ` Uwe Kleine-König
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=20260713121741.02CD21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=stefan.popa@analog.com \
/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.