From b47c0a55a3721e635d5b28f61a46161f72894394 Mon Sep 17 00:00:00 2001 From: ppisa Date: Thu, 1 Jul 2004 01:45:42 +0000 Subject: [PATCH] Some problems fixup in RTR read mode in read system-call. This mode is there for compatibility reasons with old driver version and should be moved to its own IOCTL. --- lincan/src/read.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lincan/src/read.c b/lincan/src/read.c index fa98bfe..efc3641 100644 --- a/lincan/src/read.c +++ b/lincan/src/read.c @@ -68,6 +68,9 @@ inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj, struct canmsg_t read_msg; DEBUGMSG("Remote transmission request\n"); + + copy_from_user(&read_msg, buffer, sizeof(struct canmsg_t)); + can_spin_lock_irqsave(&hardware_p->rtr_lock, flags); if (hardware_p->rtr_queue == NULL) { //No remote messages pending new_rtr_entry=(struct rtr_id *)kmalloc(sizeof(struct rtr_id),GFP_ATOMIC); @@ -98,7 +101,6 @@ inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj, interruptible_sleep_on(&new_rtr_entry->rtr_wq); can_spin_lock_irqsave(&hardware_p->rtr_lock, flags); - copy_to_user(buffer, &read_msg, sizeof(struct canmsg_t)); if (hardware_p->rtr_queue == new_rtr_entry) { if (new_rtr_entry->next != NULL) hardware_p->rtr_queue=new_rtr_entry->next; @@ -117,6 +119,8 @@ inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj, can_spin_unlock_irqrestore(&hardware_p->rtr_lock, flags); kfree(new_rtr_entry); + copy_to_user(buffer, &read_msg, sizeof(struct canmsg_t)); + return obj->ret; } @@ -154,6 +158,7 @@ ssize_t can_read(struct file *file, char *buffer, size_t length, loff_t *offset) copy_from_user(&read_msg, buffer, sizeof(struct canmsg_t)); if (read_msg.flags & MSG_RTR) + /* FIXME: RTR processing should go to its own IOCTLs */ ret = can_rtr_read(chip, obj, buffer); else ret = can_std_read(file, qends, obj, buffer, length); -- 2.39.2