From: Colin King <colin.king@canonical.com>
To: Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
sayli karnik <karniksayli1995@gmail.com>,
Matt Ranostay <mranostay@gmail.com>,
Wei Yongjun <weiyongjun1@huawei.com>,
linux-iio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size
Date: Tue, 25 Oct 2016 20:04:08 +0100 [thread overview]
Message-ID: <20161025190408.5012-1-colin.king@canonical.com> (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
next reply other threads:[~2016-10-25 19:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-25 19:04 Colin King [this message]
2016-10-25 19:11 ` Lars-Peter Clausen
2016-10-25 20:05 ` Colin Ian King
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=20161025190408.5012-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=jic23@kernel.org \
--cc=karniksayli1995@gmail.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mranostay@gmail.com \
--cc=pmeerw@pmeerw.net \
--cc=weiyongjun1@huawei.com \
/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®