From: David Lechner <dlechner@baylibre.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>, "Chris Hall" <c-hall@ti.com>,
"Patrick Edwards" <pedwards@ti.com>,
"Kurt Borja" <kuurtb@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/3] iio: adc: ti-ads112c14: add continuous mode support
Date: Mon, 31 Aug 2026 16:39:01 -0500 [thread overview]
Message-ID: <a54a8a3a-188c-4487-bf90-557f1d027c39@baylibre.com> (raw)
In-Reply-To: <20260830232418.10f23462@jic23-huawei>
On 8/30/26 5:24 PM, Jonathan Cameron wrote:
> On Sun, 30 Aug 2026 22:00:34 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
>
...
>>
>>> +static int ads112c14_buffer_postenable(struct iio_dev *indio_dev)
>>> +{
>>> + struct ads112c14_data *data = iio_priv(indio_dev);
>>> + const struct iio_chan_spec *chan;
>>> + int ret;
>>> +
>>> + if (!ads112c14_using_drdy_trigger(indio_dev))
>>> + return 0;
>>> +
>>> + chan = ads112c14_first_active_channel(indio_dev);
>>> + if (!chan)
>>> + return -EINVAL;
>>> +
>>> + guard(mutex)(&data->lock);
>>> +
>>> + ret = ads112c14_prepare_channel(data, chan);
>>
> | sashiko.dev <sashiko@sashiko.dev>:
> |
> | [Severity: High]
> | Can a user bypass the single-channel limitation and push corrupted data
> | to the ring buffer here?
> |
> | Since ads112c14_validate_scan_mask() allows multiple channels if a non-DRDY
> | trigger is currently selected, a user could enable multiple channels via
> | scan_elements, then switch current_trigger to the DRDY trigger before
> | enabling the IIO buffer.
>
>>
>> Hmm. Indeed an interesting corner... From a quick look it is correct.
>> I'm not sure if this is in practice an existing bug - do other
>> drivers change acceptable channels based on another change such as
>> which trigger is in use? Either way we need to close this.
>>
>> We can't just go clearing the set bits on setting the trigger as
>> that might cause a regression. So I think all we can do is add
>> a well commented additional check early in the buffer enable path.
>>
>> Given the behaviour that is causing problems is present in this
>> driver we could either add the protection in fix and rely on that
>> going upstream first, or add it as first patch in this series and
>> let it work its way upstream with this patch.
>>
>> Nice catch to sashiko!
>>
>
> |
> | Because this driver does not provide an available_scan_masks array, the
> | mask isn't re-validated during buffer enablement. Since
> | ads112c14_buffer_postenable() only configures the first active channel,
> | will the trigger handler push uninitialized heap memory for the remaining
> | channels when the full array is sent to userspace?
> |
> | via: https://sashiko.dev/#/message/20260827-iio-adc-ti-ads112c14-continuous-mode-v4-3-1e51a6e20a69@baylibre.com
>
Ah, I had it mixed up in my mind with update_scan_mode(), which would be
called at the appropriate time.
next prev parent reply other threads:[~2026-08-31 21:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 22:22 [PATCH v4 0/3] iio: adc: ti-ads112c14: continuous mode support David Lechner (TI)
2026-08-27 22:22 ` [PATCH v4 1/3] iio: adc: ti-ads112c14: add DRDY interrupt support David Lechner (TI)
2026-08-30 21:00 ` Jonathan Cameron
2026-08-27 22:22 ` [PATCH v4 2/3] iio: adc: ti-ads112c14: create data read helper functions David Lechner (TI)
2026-08-27 22:22 ` [PATCH v4 3/3] iio: adc: ti-ads112c14: add continuous mode support David Lechner (TI)
2026-08-30 21:00 ` Jonathan Cameron
2026-08-30 22:24 ` Jonathan Cameron
2026-08-31 21:39 ` David Lechner [this message]
2026-08-31 21:31 ` David Lechner
2026-09-01 1:51 ` Jonathan Cameron
2026-09-14 3:44 ` Shuangpeng Bai
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=a54a8a3a-188c-4487-bf90-557f1d027c39@baylibre.com \
--to=dlechner@baylibre.com \
--cc=andy@kernel.org \
--cc=c-hall@ti.com \
--cc=jic23@kernel.org \
--cc=kuurtb@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=pedwards@ti.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.