* [PATCH] iio: temperature: ltc2983: fix u32 read into a unsigned long long
@ 2019-11-05 20:28 Colin King
2019-11-06 14:19 ` Sa, Nuno
0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2019-11-05 20:28 UTC (permalink / raw)
To: Nuno Sá, Jonathan Cameron, Hartmut Knaack,
Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the read of temp using of_property_read_u32_index is reading
a u32 value into a unsigned long long. This relies on machine endianness
to work correctly, so fix this by reading a u32 value and setting temp
to this value.
Addresses-Coverity: ("Reliance on integer endianness")
Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/iio/temperature/ltc2983.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
index ddf47023364b..d39c0d6b77f1 100644
--- a/drivers/iio/temperature/ltc2983.c
+++ b/drivers/iio/temperature/ltc2983.c
@@ -444,8 +444,10 @@ static struct ltc2983_custom_sensor *__ltc2983_custom_sensor_new(
else
temp = __convert_to_raw(temp, resolution);
} else {
- of_property_read_u32_index(np, propname, index,
- (u32 *)&temp);
+ u32 t32;
+
+ of_property_read_u32_index(np, propname, index, &t32);
+ temp = t32;
}
for (j = 0; j < n_size; j++)
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: temperature: ltc2983: fix u32 read into a unsigned long long
2019-11-05 20:28 [PATCH] iio: temperature: ltc2983: fix u32 read into a unsigned long long Colin King
@ 2019-11-06 14:19 ` Sa, Nuno
2019-11-10 11:48 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Sa, Nuno @ 2019-11-06 14:19 UTC (permalink / raw)
To: linux-iio@vger.kernel.org, Jonathan.Cameron@huawei.com,
colin.king@canonical.com, knaack.h@gmx.de, pme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by90ZW1wZXJh
dHVyZS9sdGMyOTgzLmMNCj4gaW5kZXggZGRmNDcwMjMzNjRiLi5kMzljMGQ2Yjc3ZjEgMTAwNjQ0
DQo+IC0tLSBhL2RyaXZlcnMvaWlvL3RlbXBlcmF0dXJlL2x0YzI5ODMuYw0KPiArKysgYi9kcml2
ZXJzL2lpby90ZW1wZXJhdHVyZS9sdGMyOTgzLmMNCj4gQEAgLTQ0NCw4ICs0NDQsMTAgQEAgc3Rh
dGljIHN0cnVjdCBsdGMyOTgzX2N1c3RvbV9zZW5zb3INCj4gKl9fbHRjMjk4M19jdXN0b21fc2Vu
c29yX25ldygNCj4gIAkJCWVsc2UNCj4gIAkJCQl0ZW1wID0gX19jb252ZXJ0X3RvX3Jhdyh0ZW1w
LA0KPiByZXNvbHV0aW9uKTsNCj4gIAkJfSBlbHNlIHsNCj4gLQkJCW9mX3Byb3BlcnR5X3JlYWRf
dTMyX2luZGV4KG5wLCBwcm9wbmFtZSwgaW5kZXgsDQo+IC0JCQkJCQkgICAodTMyICopJnRlbXAp
Ow0KPiArCQkJdTMyIHQzMjsNCj4gKw0KPiArCQkJb2ZfcHJvcGVydHlfcmVhZF91MzJfaW5kZXgo
bnAsIHByb3BuYW1lLCBpbmRleCwNCj4gJnQzMik7DQo+ICsJCQl0ZW1wID0gdDMyOw0KPiAgCQl9
DQo+ICANCj4gIAkJZm9yIChqID0gMDsgaiA8IG5fc2l6ZTsgaisrKQ0KDQpBY2tlZC1ieTogTnVu
byBTw6EgPG51bm8uc2FAYW5hbG9nLmNvbT4NCg0KVGhhbmtzLA0KTnVubyBTw6ENCg=
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: temperature: ltc2983: fix u32 read into a unsigned long long
2019-11-06 14:19 ` Sa, Nuno
@ 2019-11-10 11:48 ` Jonathan Cameron
2019-11-16 15:15 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2019-11-10 11:48 UTC (permalink / raw)
To: Sa, Nuno
Cc: linux-iio@vger.kernel.org, Jonathan.Cameron@huawei.com,
colin.king@canonical.com, knaack.h@gmx.de, pmeerw@pmeerw.net,
lars@metafoo.de, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wed, 6 Nov 2019 14:19:52 +0000
"Sa, Nuno" <Nuno.Sa@analog.com> wrote:
> On Tue, 2019-11-05 at 20:28 +0000, Colin King wrote:
> >
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > Currently the read of temp using of_property_read_u32_index is
> > reading
> > a u32 value into a unsigned long long. This relies on machine
> > endianness
> > to work correctly, so fix this by reading a u32 value and setting
> > temp
> > to this value.
> >
> > Addresses-Coverity: ("Reliance on integer endianness")
> > Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > drivers/iio/temperature/ltc2983.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/temperature/ltc2983.c
> > b/drivers/iio/temperature/ltc2983.c
> > index ddf47023364b..d39c0d6b77f1 100644
> > --- a/drivers/iio/temperature/ltc2983.c
> > +++ b/drivers/iio/temperature/ltc2983.c
> > @@ -444,8 +444,10 @@ static struct ltc2983_custom_sensor
> > *__ltc2983_custom_sensor_new(
> > else
> > temp = __convert_to_raw(temp,
> > resolution);
> > } else {
> > - of_property_read_u32_index(np, propname, index,
> > - (u32 *)&temp);
> > + u32 t32;
> > +
> > + of_property_read_u32_index(np, propname, index,
> > &t32);
> > + temp = t32;
> > }
> >
> > for (j = 0; j < n_size; j++)
>
> Acked-by: Nuno Sá <nuno.sa@analog.com>
>
A slight complexity around this one. I'm not sure I'll have time for a pull
before the merge window (as Greg will only take them to about 1 week before
that opens so we get some exposure in Linux next).
As a result I'll have to sit on this one until Linus comments on rc7, probably
later today. Otherwise it'll be material for stable post release.
If I seem to have lost it give me a poke and we'll make sure it goes into
an early rc instead of at the merge window.
Thanks,
Jonathan
> Thanks,
> Nuno Sá
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: temperature: ltc2983: fix u32 read into a unsigned long long
2019-11-10 11:48 ` Jonathan Cameron
@ 2019-11-16 15:15 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2019-11-16 15:15 UTC (permalink / raw)
To: Sa, Nuno
Cc: linux-iio@vger.kernel.org, Jonathan.Cameron@huawei.com,
colin.king@canonical.com, knaack.h@gmx.de, pmeerw@pmeerw.net,
lars@metafoo.de, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
On Sun, 10 Nov 2019 11:48:23 +0000
Jonathan Cameron <jic23@kernel.org> wrote:
> On Wed, 6 Nov 2019 14:19:52 +0000
> "Sa, Nuno" <Nuno.Sa@analog.com> wrote:
>
> > On Tue, 2019-11-05 at 20:28 +0000, Colin King wrote:
> > >
> > > From: Colin Ian King <colin.king@canonical.com>
> > >
> > > Currently the read of temp using of_property_read_u32_index is
> > > reading
> > > a u32 value into a unsigned long long. This relies on machine
> > > endianness
> > > to work correctly, so fix this by reading a u32 value and setting
> > > temp
> > > to this value.
> > >
> > > Addresses-Coverity: ("Reliance on integer endianness")
> > > Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983")
> > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > > ---
> > > drivers/iio/temperature/ltc2983.c | 6 ++++--
> > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/iio/temperature/ltc2983.c
> > > b/drivers/iio/temperature/ltc2983.c
> > > index ddf47023364b..d39c0d6b77f1 100644
> > > --- a/drivers/iio/temperature/ltc2983.c
> > > +++ b/drivers/iio/temperature/ltc2983.c
> > > @@ -444,8 +444,10 @@ static struct ltc2983_custom_sensor
> > > *__ltc2983_custom_sensor_new(
> > > else
> > > temp = __convert_to_raw(temp,
> > > resolution);
> > > } else {
> > > - of_property_read_u32_index(np, propname, index,
> > > - (u32 *)&temp);
> > > + u32 t32;
> > > +
> > > + of_property_read_u32_index(np, propname, index,
> > > &t32);
> > > + temp = t32;
> > > }
> > >
> > > for (j = 0; j < n_size; j++)
> >
> > Acked-by: Nuno Sá <nuno.sa@analog.com>
> >
>
> A slight complexity around this one. I'm not sure I'll have time for a pull
> before the merge window (as Greg will only take them to about 1 week before
> that opens so we get some exposure in Linux next).
>
> As a result I'll have to sit on this one until Linus comments on rc7, probably
> later today. Otherwise it'll be material for stable post release.
>
> If I seem to have lost it give me a poke and we'll make sure it goes into
> an early rc instead of at the merge window.
I forgot about it when I sent the final pull request out. Sorry about that,
will have to wait for post merge window.
Applied to the fixes-togreg branch of iio.git.
Thanks,
Jonathan
>
> Thanks,
>
> Jonathan
>
> > Thanks,
> > Nuno Sá
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-16 15:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-05 20:28 [PATCH] iio: temperature: ltc2983: fix u32 read into a unsigned long long Colin King
2019-11-06 14:19 ` Sa, Nuno
2019-11-10 11:48 ` Jonathan Cameron
2019-11-16 15:15 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).