Skip to content

Commit

Permalink
utils: iio_rwdev: fix cancelling streaming
Browse files Browse the repository at this point in the history
If we try to cancel the utility with a signal, we'll cancel the buffer (at
least on linux) which means we'll likely fail to dequeue a block if we
are waiting for one. On top of that the flag 'app_running' is set to false
which means that the loop condition '(ret && app_running)' is false and
so we do not leave it. This all means that we'll proceed with an
invalid block leading to a segfault.

Hence, always break the loop if iio_stream_get_next_block() fails (which
was the previous behavior) but only log it if the application is
running.

Signed-off-by: Nuno Sá <[email protected]>
  • Loading branch information
nunojsa authored and dNechita committed Jan 30, 2025
1 parent fd60090 commit e8c251b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/iio_rwdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,9 @@ int main(int argc, char **argv)

block = iio_stream_get_next_block(stream);
ret = iio_err(block);
if (ret && app_running) {
dev_perror(dev, ret, "Unable to get next block");
if (ret) {
if (app_running)
dev_perror(dev, ret, "Unable to get next block");
break;
}

Expand Down

0 comments on commit e8c251b

Please sign in to comment.