diff options
author | Pan Bian <bianpan2016@163.com> | 2016-12-05 12:37:24 +0100 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2016-12-09 13:46:29 +0100 |
commit | c60fa555b11b25386b355c141d90cbee361c3eec (patch) | |
tree | 144f457fbc9ebfcb02a4c98a4009fd0f3b402d62 /drivers/hid | |
parent | HID: microsoft: Add Surface 4 type cover pro 4 not JP versions (diff) | |
download | linux-c60fa555b11b25386b355c141d90cbee361c3eec.tar.xz linux-c60fa555b11b25386b355c141d90cbee361c3eec.zip |
HID: usbhid: fix improper return value
Function hid_post_reset() should return negative error codes on failures.
However, in its implementation, it incorrectly returns 1. This patch fixes the
bug, returning proper error codes on failures.
Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index ae83af649a60..333108ef18cf 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1459,7 +1459,7 @@ static int hid_post_reset(struct usb_interface *intf) rdesc = kmalloc(hid->dev_rsize, GFP_KERNEL); if (!rdesc) { dbg_hid("couldn't allocate rdesc memory (post_reset)\n"); - return 1; + return -ENOMEM; } status = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, @@ -1467,13 +1467,13 @@ static int hid_post_reset(struct usb_interface *intf) if (status < 0) { dbg_hid("reading report descriptor failed (post_reset)\n"); kfree(rdesc); - return 1; + return status; } status = memcmp(rdesc, hid->dev_rdesc, hid->dev_rsize); kfree(rdesc); if (status != 0) { dbg_hid("report descriptor changed\n"); - return 1; + return -EPERM; } /* No need to do another reset or clear a halted endpoint */ |