Skip to content

Commit

Permalink
driver: prevent reading a free block
Browse files Browse the repository at this point in the history
when you read the stream device without arming PCAP, you get garbage
which comes from reading uninitialised buffers, to fix that, we need
to wait for the block to contain data
  • Loading branch information
EmilioPeJu committed Jul 26, 2023
1 parent fdfa60a commit 750f861
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion driver/panda_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ static int wait_for_block(struct stream_open *open)
{
struct block *block = &open->blocks[open->read_block_index];
int rc = wait_event_interruptible_timeout(open->wait_queue,
block->state != BLOCK_DMA, HZ);
block->state == BLOCK_DATA || block->state == BLOCK_DATA_END, HZ);
if (rc == 0)
/* Normal timeout. Tell caller they can try again. */
return -EAGAIN;
Expand Down

0 comments on commit 750f861

Please sign in to comment.