diff --git a/mouse-driver/mousek.c b/mouse-driver/mousek.c index 376a545..449dd1f 100644 --- a/mouse-driver/mousek.c +++ b/mouse-driver/mousek.c @@ -65,6 +65,12 @@ int Major; +static int mousek_open(struct inode *inode, struct file *filp); +static int mousek_release(struct inode *inode, struct file *filp); +static ssize_t mousek_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos); +static ssize_t mousek_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos); + + /* * We need a local data structure, as it must be allocated for each new * mouse device plugged in the USB bus @@ -176,7 +182,9 @@ /* accept 16 bytes at a time, at most */ if (count > 16) count = 16; - copy_from_user(localbuf, buf, count); + if (copy_from_user(localbuf, buf, count)) { + return -EFAULT; + } /* prepare the urb for mousek_irq() */ // urb.status = USB_ST_NOERROR; @@ -530,4 +538,4 @@ // ret = free_irq(BUTTON_IRQ, mousek_interrupt); // if (ret < 0) // printk(KERN_ALERT "Error in freeing irq: %d\n", ret); -} \ No newline at end of file +}