Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1536015 > unrolled thread

[PATCH 1/1 v2] input: usbhid: fix improper return value

Started byPan Bian <bianpan2016@163.com>
First post2016-12-05 12:40 +0100
Last post2016-12-09 13:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1 v2] input: usbhid: fix improper return value Pan Bian <bianpan2016@163.com> - 2016-12-05 12:40 +0100
    Re: [PATCH 1/1 v2] input: usbhid: fix improper return value Jiri Kosina <jikos@kernel.org> - 2016-12-09 13:50 +0100

#1536015 — [PATCH 1/1 v2] input: usbhid: fix improper return value

FromPan Bian <bianpan2016@163.com>
Date2016-12-05 12:40 +0100
Subject[PATCH 1/1 v2] input: usbhid: fix improper return value
Message-ID<sKZMK-3Vo-17@gated-at.bofh.it>
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>
---
 drivers/hid/usbhid/hid-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index ae83af6..333108e 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 */
-- 
1.9.1

[toc] | [next] | [standalone]


#1539326

FromJiri Kosina <jikos@kernel.org>
Date2016-12-09 13:50 +0100
Message-ID<sMsMF-3hS-11@gated-at.bofh.it>
In reply to#1536015
On Mon, 5 Dec 2016, Pan Bian wrote:

> 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.

Applied to for-4.10/upstream. Thanks,

-- 
Jiri Kosina
SUSE Labs

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web