mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size
@ 2016-10-25 19:04 Colin King
  2016-10-25 19:11 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2016-10-25 19:04 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, sayli karnik, Matt Ranostay, Wei Yongjun,
	linux-iio
  Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

In the case that the read size is not 2 or 4 bytes
then maxim_thermocouple_read is not initializing ret and
hence may return early with a bogus error return or
just through to return with a bogos unread value in *val.
Fix this by setting ret to -EINVAL for invalid (unhandled)
read sizes.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/iio/temperature/maxim_thermocouple.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c
index 066161a..f962f31 100644
--- a/drivers/iio/temperature/maxim_thermocouple.c
+++ b/drivers/iio/temperature/maxim_thermocouple.c
@@ -136,6 +136,8 @@ static int maxim_thermocouple_read(struct maxim_thermocouple_data *data,
 		ret = spi_read(data->spi, (void *)&buf32, storage_bytes);
 		*val = be32_to_cpu(buf32);
 		break;
+	default:
+		ret = -EINVAL;
 	}
 
 	if (ret)
-- 
2.9.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size
  2016-10-25 19:04 [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size Colin King
@ 2016-10-25 19:11 ` Lars-Peter Clausen
  2016-10-25 20:05   ` Colin Ian King
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2016-10-25 19:11 UTC (permalink / raw)
  To: Colin King, Jonathan Cameron, Hartmut Knaack,
	Peter Meerwald-Stadler, sayli karnik, Matt Ranostay, Wei Yongjun,
	linux-iio
  Cc: linux-kernel

On 10/25/2016 09:04 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> In the case that the read size is not 2 or 4 bytes
> then maxim_thermocouple_read is not initializing ret and
> hence may return early with a bogus error return or
> just through to return with a bogos unread value in *val.
> Fix this by setting ret to -EINVAL for invalid (unhandled)
> read sizes.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Again, Arnd already took the prize, https://lkml.org/lkml/2016/10/25/518

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size
  2016-10-25 19:11 ` Lars-Peter Clausen
@ 2016-10-25 20:05   ` Colin Ian King
  0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2016-10-25 20:05 UTC (permalink / raw)
  To: Lars-Peter Clausen, Jonathan Cameron, Hartmut Knaack,
	Peter Meerwald-Stadler, sayli karnik, Matt Ranostay, Wei Yongjun,
	linux-iio
  Cc: linux-kernel

On 25/10/16 20:11, Lars-Peter Clausen wrote:
> On 10/25/2016 09:04 PM, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> In the case that the read size is not 2 or 4 bytes
>> then maxim_thermocouple_read is not initializing ret and
>> hence may return early with a bogus error return or
>> just through to return with a bogos unread value in *val.
>> Fix this by setting ret to -EINVAL for invalid (unhandled)
>> read sizes.
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> Again, Arnd already took the prize, https://lkml.org/lkml/2016/10/25/518
> 
Not my day :-)

Colin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-25 20:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25 19:04 [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size Colin King
2016-10-25 19:11 ` Lars-Peter Clausen
2016-10-25 20:05   ` Colin Ian King

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®