diff options
author | Jarod Wilson <jarod@redhat.com> | 2011-03-04 17:53:05 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 18:24:21 -0400 |
commit | cc664ae026f1b0f3254564a7d45cc29e735c7fed (patch) | |
tree | a2c0eaa8ffbac79aa0eea591dfb0eb82f7282430 | |
parent | 55734785cdaff596be9a5238af54fc0f4ace2e63 (diff) |
[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: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/staging/lirc/lirc_zilog.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c index 407d4b409a8b..dd6a57c3c3a3 100644 --- a/drivers/staging/lirc/lirc_zilog.c +++ b/drivers/staging/lirc/lirc_zilog.c | |||
@@ -897,7 +897,7 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) | |||
897 | struct IR *ir = filep->private_data; | 897 | struct IR *ir = filep->private_data; |
898 | struct IR_rx *rx; | 898 | struct IR_rx *rx; |
899 | struct lirc_buffer *rbuf = ir->l.rbuf; | 899 | struct lirc_buffer *rbuf = ir->l.rbuf; |
900 | int ret = 0, written = 0; | 900 | int ret = 0, written = 0, retries = 0; |
901 | unsigned int m; | 901 | unsigned int m; |
902 | DECLARE_WAITQUEUE(wait, current); | 902 | DECLARE_WAITQUEUE(wait, current); |
903 | 903 | ||
@@ -950,6 +950,12 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) | |||
950 | ret = copy_to_user((void *)outbuf+written, buf, | 950 | ret = copy_to_user((void *)outbuf+written, buf, |
951 | rbuf->chunk_size); | 951 | rbuf->chunk_size); |
952 | written += rbuf->chunk_size; | 952 | written += rbuf->chunk_size; |
953 | } else { | ||
954 | retries++; | ||
955 | } | ||
956 | if (retries >= 5) { | ||
957 | zilog_error("Buffer read failed!\n"); | ||
958 | ret = -EIO; | ||
953 | } | 959 | } |
954 | } | 960 | } |
955 | } | 961 | } |