HID: roccat: Fix an error message when reading more data from bin attributes
authorStefan Achatz <erazor_de@users.sourceforge.net>
Thu, 6 Jan 2011 08:00:41 +0000 (09:00 +0100)
committerJiri Kosina <jkosina@suse.cz>
Thu, 20 Jan 2011 10:28:53 +0000 (11:28 +0100)
Using cat or something to read from binary attributes would try to do an
additional read with offset equal to filesize. This resulted in an invalid
attribute error. This is fixed by giving the right answer instead of EINVAL.

Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-roccat-koneplus.c

index 591a97cf6b65b70bd508e4afe2a2401934249ddf..65d7cde4c5d191d7365ee371c7253f0a87757ec2 100644 (file)
@@ -258,6 +258,9 @@ static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj,
        struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
        int retval;
 
+       if (off >= real_size)
+               return 0;
+
        if (off != 0 || count != real_size)
                return -EINVAL;