From: Jonathan Cameron <jic23@kernel.org>
To: Peter Rosin <peda@axentia.se>, Colin Ian King <colin.king@canonical.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: multiplexer: fix unsigned check with less than zero
Date: Sat, 11 Mar 2017 18:30:36 +0000 [thread overview]
Message-ID: <d91161d3-3795-af99-16ba-31de49cc42a4@kernel.org> (raw)
In-Reply-To: <1488979698-12545-1-git-send-email-peda@axentia.se>
On 08/03/17 13:28, Peter Rosin wrote:
> Comparing a size_t with less than zero is always false as size_t
> is unsigned. So, change the type of the variable to ssize_t and
> replicate the size check from mux_configure_channel() into
> mux_write_ext_info() thus ensuring that the size will fit in the
> ssize_t variable.
>
> Detected by CoverityScan, CID#1415278 ("Unsigned compared against 0")
>
> Reported-by: Colin Ian King <colin.king@canonical.com>
> Signed-off-by: Peter Rosin <peda@axentia.se>
For what it's worth, looks good to me.
Jonathan
> ---
> drivers/iio/multiplexer/iio-mux.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> Hi!
>
> Here's what intend to queue up.
>
> Cheers,
> peda
>
> diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c
> index 94d40f9b..bab9e69 100644
> --- a/drivers/iio/multiplexer/iio-mux.c
> +++ b/drivers/iio/multiplexer/iio-mux.c
> @@ -21,7 +21,7 @@
>
> struct mux_ext_info_cache {
> char *data;
> - size_t size;
> + ssize_t size;
> };
>
> struct mux_child {
> @@ -206,6 +206,9 @@ static ssize_t mux_write_ext_info(struct iio_dev *indio_dev, uintptr_t private,
> char *new;
> ssize_t ret;
>
> + if (len >= PAGE_SIZE)
> + return -EINVAL;
> +
> ret = iio_mux_select(mux, idx);
> if (ret < 0)
> return ret;
>
prev parent reply other threads:[~2017-03-11 18:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-07 15:06 [PATCH] " Colin King
2017-03-08 8:59 ` Peter Rosin
2017-03-08 9:03 ` Colin Ian King
2017-03-08 13:28 ` [PATCH v2] " Peter Rosin
2017-03-11 18:30 ` 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=d91161d3-3795-af99-16ba-31de49cc42a4@kernel.org \
--to=jic23@kernel.org \
--cc=colin.king@canonical.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--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
all inboxes | Powered by JetHome®