From: Jonathan Cameron <jic23@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio: sca3000: Potential endian bug in sca3000_read_event_value()
Date: Sat, 22 Jun 2019 09:43:26 +0100 [thread overview]
Message-ID: <20190622094326.742d3e7e@archlinux> (raw)
In-Reply-To: <20190621091828.GA1878@mwanda>
On Fri, 21 Jun 2019 12:18:28 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> The problem is that "ret" is an int but we're casting it as
> "(unsigned long *)&ret" when we do the for_each_set_bit() loop. This
> will not work on big endian 64 bit systems.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Hi Dan,
Great catch, I've applied this to the togreg branch of iio.git (rather
than fixes) given the point in the cycle and limited chance anyone is
actually running this obsolete part on a be64 machine. I would love
to be proved wrong though and would be happy to push this for stable
if we do get any reports!
Thanks,
Jonathan
> ---
> drivers/iio/accel/sca3000.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
> index 4964561595f5..9e9f4347a325 100644
> --- a/drivers/iio/accel/sca3000.c
> +++ b/drivers/iio/accel/sca3000.c
> @@ -872,8 +872,9 @@ static int sca3000_read_event_value(struct iio_dev *indio_dev,
> enum iio_event_info info,
> int *val, int *val2)
> {
> - int ret, i;
> struct sca3000_state *st = iio_priv(indio_dev);
> + long ret;
> + int i;
>
> switch (info) {
> case IIO_EV_INFO_VALUE:
> @@ -885,11 +886,11 @@ static int sca3000_read_event_value(struct iio_dev *indio_dev,
> return ret;
> *val = 0;
> if (chan->channel2 == IIO_MOD_Y)
> - for_each_set_bit(i, (unsigned long *)&ret,
> + for_each_set_bit(i, &ret,
> ARRAY_SIZE(st->info->mot_det_mult_y))
> *val += st->info->mot_det_mult_y[i];
> else
> - for_each_set_bit(i, (unsigned long *)&ret,
> + for_each_set_bit(i, &ret,
> ARRAY_SIZE(st->info->mot_det_mult_xz))
> *val += st->info->mot_det_mult_xz[i];
>
prev parent reply other threads:[~2019-06-22 8:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-21 9:18 [PATCH] iio: sca3000: Potential endian bug in sca3000_read_event_value() Dan Carpenter
2019-06-22 8:43 ` Jonathan Cameron [this message]
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=20190622094326.742d3e7e@archlinux \
--to=jic23@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=gustavo@embeddedor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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