From patchwork Mon Dec 5 11:37:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pan Bian X-Patchwork-Id: 9460885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3ACEA60459 for ; Mon, 5 Dec 2016 11:39:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BE0824B44 for ; Mon, 5 Dec 2016 11:39:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F1FB26224; Mon, 5 Dec 2016 11:39:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8252524B44 for ; Mon, 5 Dec 2016 11:39:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751241AbcLELjc (ORCPT ); Mon, 5 Dec 2016 06:39:32 -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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=aGXwCQzAFT9ezVVZf7 s5oBEWviW0kAEoYwOfgxyHUuk=; b=LHk7dphYE0lJ0qppVbrTljLcQDDn1lzoyR GaMYSFfWcir8z/RRbpYsK6FwAuEXN6JKEvxk5zTXlyK801GvRgu4CREmEG/v6wpw I8/qta3fPmg1TsgKhtydTOyaduW9mMVDqW8M8yXlR53+h1eGGXahto4ZL01JTVtq dSk5QQ3QI= Received: from localhost.localdomain (unknown [106.120.213.17]) by smtp7 (Coremail) with SMTP id C8CowAC3pdpzUUVYrzgvFA--.45925S3; Mon, 05 Dec 2016 19:37:26 +0800 (CST) 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-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 */