Commit c60fa555 authored by Pan Bian's avatar Pan Bian Committed by Jiri Kosina

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: default avatarPan Bian <bianpan2016@163.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 2ae3986b
...@@ -1459,7 +1459,7 @@ static int hid_post_reset(struct usb_interface *intf) ...@@ -1459,7 +1459,7 @@ static int hid_post_reset(struct usb_interface *intf)
rdesc = kmalloc(hid->dev_rsize, GFP_KERNEL); rdesc = kmalloc(hid->dev_rsize, GFP_KERNEL);
if (!rdesc) { if (!rdesc) {
dbg_hid("couldn't allocate rdesc memory (post_reset)\n"); dbg_hid("couldn't allocate rdesc memory (post_reset)\n");
return 1; return -ENOMEM;
} }
status = hid_get_class_descriptor(dev, status = hid_get_class_descriptor(dev,
interface->desc.bInterfaceNumber, interface->desc.bInterfaceNumber,
...@@ -1467,13 +1467,13 @@ static int hid_post_reset(struct usb_interface *intf) ...@@ -1467,13 +1467,13 @@ static int hid_post_reset(struct usb_interface *intf)
if (status < 0) { if (status < 0) {
dbg_hid("reading report descriptor failed (post_reset)\n"); dbg_hid("reading report descriptor failed (post_reset)\n");
kfree(rdesc); kfree(rdesc);
return 1; return status;
} }
status = memcmp(rdesc, hid->dev_rdesc, hid->dev_rsize); status = memcmp(rdesc, hid->dev_rdesc, hid->dev_rsize);
kfree(rdesc); kfree(rdesc);
if (status != 0) { if (status != 0) {
dbg_hid("report descriptor changed\n"); dbg_hid("report descriptor changed\n");
return 1; return -EPERM;
} }
/* No need to do another reset or clear a halted endpoint */ /* No need to do another reset or clear a halted endpoint */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment