linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Colin King <colin.king@canonical.com>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Brian Norris <briannorris@chromium.org>
Subject: Re: [PATCH] iio: ensure ret is initialized to zero before entering do loop
Date: Mon, 5 Sep 2016 21:03:26 +0100	[thread overview]
Message-ID: <59ac3528-2245-ea61-f7e7-847bc5fe90b9@kernel.org> (raw)
In-Reply-To: <20160905143906.13579-1-colin.king@canonical.com>

On 05/09/16 15:39, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> A recent fix to iio_buffer_read_first_n_outer removed ret from being set by
> a return from wait_event_interruptible and also added a continue in a loop
> which causes the variable ret to not be set when it reaches the end of the
> loop.  Fix this by initializing ret to zero.
> 
> Also remove extraneous white space at the end of the loop.
> 
> Fixes: fcf68f3c0bb2a5 ("fix sched WARNING "do not call blocking ops when !TASK_RUNNING")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Good find.  Strange that got through 0-day without a warning...

Cc'd Brian as author of the fix this is fixing.
Brian can you sanity check this patch as well.

Applied to the fixes-togreg branch of iio.git and marked for stable.
Ah well, another one for the statistics on stable patches that introduce bugs while
fixing other bugs.

Pretty unlikely this will be hit I think, but in theory you never know.

Jonathan
> ---
>  drivers/iio/industrialio-buffer.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 49bf9c5..158aaf4 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -110,7 +110,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
>  	DEFINE_WAIT_FUNC(wait, woken_wake_function);
>  	size_t datum_size;
>  	size_t to_wait;
> -	int ret;
> +	int ret = 0;
>  
>  	if (!indio_dev->info)
>  		return -ENODEV;
> @@ -153,7 +153,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
>  		ret = rb->access->read_first_n(rb, n, buf);
>  		if (ret == 0 && (filp->f_flags & O_NONBLOCK))
>  			ret = -EAGAIN;
> -	 } while (ret == 0);
> +	} while (ret == 0);
>  	remove_wait_queue(&rb->pollq, &wait);
>  
>  	return ret;
> 

  reply	other threads:[~2016-09-05 20:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05 14:39 [PATCH] iio: ensure ret is initialized to zero before entering do loop Colin King
2016-09-05 20:03 ` Jonathan Cameron [this message]
2016-09-06 17:10   ` Brian Norris
2016-09-07 19:10     ` Jonathan Cameron

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=59ac3528-2245-ea61-f7e7-847bc5fe90b9@kernel.org \
    --to=jic23@kernel.org \
    --cc=briannorris@chromium.org \
    --cc=colin.king@canonical.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).