Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc664ae0 authored by Jarod Wilson's avatar Jarod Wilson Committed by Mauro Carvalho Chehab
Browse files

[media] lirc_zilog: error out if buffer read bytes != chunk size



Give it a few tries, then exit. Prevents a possible endless loop
situation.

Signed-off-by: default avatarJarod Wilson <jarod@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 55734785
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -897,7 +897,7 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
	struct IR *ir = filep->private_data;
	struct IR_rx *rx;
	struct lirc_buffer *rbuf = ir->l.rbuf;
	int ret = 0, written = 0;
	int ret = 0, written = 0, retries = 0;
	unsigned int m;
	DECLARE_WAITQUEUE(wait, current);

@@ -950,6 +950,12 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
				ret = copy_to_user((void *)outbuf+written, buf,
						   rbuf->chunk_size);
				written += rbuf->chunk_size;
			} else {
				retries++;
			}
			if (retries >= 5) {
				zilog_error("Buffer read failed!\n");
				ret = -EIO;
			}
		}
	}