From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Antoni Pokusinski" <apokusinski01@gmail.com>,
"Francesco Dolcini" <francesco@dolcini.it>,
"João Paulo Gonçalves" <jpaulo.silvagoncalves@gmail.com>,
"Christian Eggers" <ceggers@arri.de>
Cc: "Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"João Paulo Gonçalves" <joao.goncalves@toradex.com>,
"Francesco Dolcini" <francesco.dolcini@toradex.com>,
"Javier Carrasco" <javier.carrasco.cruz@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v2 2/2] iio: light: as73211: fix channel handling in only-color triggered buffer
Date: Wed, 04 Dec 2024 00:55:32 +0100 [thread overview]
Message-ID: <20241204-iio_memset_scan_holes-v2-2-3f941592a76d@gmail.com> (raw)
In-Reply-To: <20241204-iio_memset_scan_holes-v2-0-3f941592a76d@gmail.com>
The channel index is off by one unit if AS73211_SCAN_MASK_ALL is not
set (optimized path for color channel readings), and it must be shifted
instead of leaving an empty channel for the temperature when it is off.
Once the channel index is fixed, the uninitialized channel must be set
to zero to avoid pushing uninitialized data.
Cc: stable@vger.kernel.org
Fixes: 403e5586b52e ("iio: light: as73211: New driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/iio/light/as73211.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/light/as73211.c b/drivers/iio/light/as73211.c
index be0068081ebb..2d45dfeda406 100644
--- a/drivers/iio/light/as73211.c
+++ b/drivers/iio/light/as73211.c
@@ -672,9 +672,12 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
/* AS73211 starts reading at address 2 */
ret = i2c_master_recv(data->client,
- (char *)&scan.chan[1], 3 * sizeof(scan.chan[1]));
+ (char *)&scan.chan[0], 3 * sizeof(scan.chan[0]));
if (ret < 0)
goto done;
+
+ /* Avoid pushing uninitialized data */
+ scan.chan[3] = 0;
}
if (data_result) {
@@ -682,9 +685,15 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
* Saturate all channels (in case of overflows). Temperature channel
* is not affected by overflows.
*/
- scan.chan[1] = cpu_to_le16(U16_MAX);
- scan.chan[2] = cpu_to_le16(U16_MAX);
- scan.chan[3] = cpu_to_le16(U16_MAX);
+ if (*indio_dev->active_scan_mask == AS73211_SCAN_MASK_ALL) {
+ scan.chan[1] = cpu_to_le16(U16_MAX);
+ scan.chan[2] = cpu_to_le16(U16_MAX);
+ scan.chan[3] = cpu_to_le16(U16_MAX);
+ } else {
+ scan.chan[0] = cpu_to_le16(U16_MAX);
+ scan.chan[1] = cpu_to_le16(U16_MAX);
+ scan.chan[2] = cpu_to_le16(U16_MAX);
+ }
}
iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
--
2.43.0
next prev parent reply other threads:[~2024-12-03 23:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-03 23:55 [PATCH v2 0/2] iio: fix information leaks in triggered buffers Javier Carrasco
2024-12-03 23:55 ` [PATCH v2 1/2] iio: temperature: tmp006: fix information leak in triggered buffer Javier Carrasco
2024-12-08 16:52 ` Jonathan Cameron
2024-12-03 23:55 ` Javier Carrasco [this message]
2024-12-04 16:20 ` [PATCH v2 2/2] iio: light: as73211: fix channel handling in only-color " Christian Eggers
2024-12-08 16:58 ` Jonathan Cameron
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=20241204-iio_memset_scan_holes-v2-2-3f941592a76d@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=apokusinski01@gmail.com \
--cc=ceggers@arri.de \
--cc=francesco.dolcini@toradex.com \
--cc=francesco@dolcini.it \
--cc=jic23@kernel.org \
--cc=joao.goncalves@toradex.com \
--cc=jpaulo.silvagoncalves@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®