Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1508560

[PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size

From Colin King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size
Date 2016-10-25 21:10 +0200
Message-ID <swfgJ-1ib-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size Colin King <colin.king@canonical.com> - 2016-10-25 21:10 +0200
  Re: [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read  size Lars-Peter Clausen <lars@metafoo.de> - 2016-10-25 21:20 +0200
    Re: [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read  size Colin Ian King <colin.king@canonical.com> - 2016-10-25 22:10 +0200

csiph-web