Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751601AbcLELjd (ORCPT ); Mon, 5 Dec 2016 06:39:33 -0500 Received: from m12-11.163.com ([220.181.12.11]:37536 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751201AbcLELjb (ORCPT ); Mon, 5 Dec 2016 06:39:31 -0500 From: Pan Bian To: Oliver Neukum , Jiri Kosina , Benjamin Tissoires , linux-usb@vger.kernel.org, linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1 v2] input: usbhid: fix improper return value Date: Mon, 5 Dec 2016 19:37:24 +0800 Message-Id: <1480937844-21513-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: C8CowAC3pdpzUUVYrzgvFA--.45925S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cw13GryktF4kJF47XrW8JFb_yoW8Jw4xpr WkGFZFyFyDJrsIvF48J3WfAFy5ua1xKFy29ryUu3s8ZF15JrW8JryfAryYqr4DAFW8Cry3 GF4v9347ua1UKFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07brR6wUUUUU= X-Originating-IP: [106.120.213.17] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiDhY3clXlhnmqeAAAsA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1298 Lines: 41 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 --- 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