X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/fd883ff8b15778611731b6e7c9cdacb5470c3901..46e2f34c15f734054295e3a2a2d68828247bcd86:/lincan/src/read.c diff --git a/lincan/src/read.c b/lincan/src/read.c index c16c76b..a6f5305 100644 --- a/lincan/src/read.c +++ b/lincan/src/read.c @@ -54,19 +54,21 @@ ssize_t can_read(struct file *file, char *buffer, size_t length, loff_t *offset) } } - copy_to_user(buffer, &slot->msg, sizeof(struct canmsg_t)); + ret = copy_to_user(buffer, &slot->msg, sizeof(struct canmsg_t)); canque_free_outslot(qends, qedge, slot); buffer += sizeof(struct canmsg_t); bytes_to_copy = length-sizeof(struct canmsg_t); + if(ret) return -EFAULT; while (bytes_to_copy > 0) { ret=canque_test_outslot(qends, &qedge, &slot); if(ret<0) break; - copy_to_user(buffer, &slot->msg, sizeof(struct canmsg_t)); + ret = copy_to_user(buffer, &slot->msg, sizeof(struct canmsg_t)); canque_free_outslot(qends, qedge, slot); buffer += sizeof(struct canmsg_t); bytes_to_copy -= sizeof(struct canmsg_t); + if(ret) return -EFAULT; } return length-bytes_to_copy;