Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4485073ybx; Mon, 4 Nov 2019 14:12:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwE8gL+LK2mEHsK38syozkTQ6Eny4+RIxLo8EXDnHtx+64UWQm3fdfajmUVRP8MK3PgwxD8 X-Received: by 2002:a17:906:300a:: with SMTP id 10mr26400268ejz.104.1572905537448; Mon, 04 Nov 2019 14:12:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905537; cv=none; d=google.com; s=arc-20160816; b=H8hnWOcF5ZkBlyb8g/aGa5W1/pJPjwOXlZjE/66NlSyuKf7Bch5KI65quieOe4ATUw wWXQJqTzepdSY6Y3siCfQd18xq781+M71HV4L3GwD0vSx6oiZ+sX8hfd86EiLaYr1sfe BCYLifUOeD5eTAPd7wL0i3O1wrpCphbUYSYbWq1gPU93/wj3k90NXH5Ofj82/eUwxIY6 wRoT90uItKmkKEXBVQfQgUGsKf0uasUpncZtfjKDGG3aY8kK1HisgSjj665UKWxhouOH 5u1IU1crtnPWfAxD92DN8XAZ0J/g/yVaFYMJI6/P6AlTFVf6bWI8h7ZvATbo6rbHrRiB u6MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vi749WFxXwOt5ObnMPAbHBxf2u+4KTv1Z5HwdSVfanQ=; b=y1xsJxQcV65KTfsX/vidXNO71Nr5YkGhhChpkJfCxdLW1Xhrd3M9hsP2SYYrZBoTVx CsMt9v40mwg7e3RkGjWcmT/6aDzpXQRABYPvWYgXLDGG4vLzy3Mot6AqNmIhAKN4jO9w wHvmXWYVrgPj0gRmyZwvpNKO9dV8G/2OPruo/1YP1VJnlBd/pfeEfKk/6qdoQm7mdiNJ WQJSU+MVBebb/Ap5mkZI5Re/vs3cbPK6zGJ1rv89VHT155rHrndcnrOOkkzV4+uLS2fa 5FLqST9IVHiGo4qa07lCMBC1TLN8zjtBoV+KdMGzCCVSFd+vVD/FXBbV5G7s41UdA2MS fOAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YyAlpEjW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11si12353602eje.376.2019.11.04.14.11.53; Mon, 04 Nov 2019 14:12:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YyAlpEjW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390373AbfKDWJS (ORCPT + 99 others); Mon, 4 Nov 2019 17:09:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:42272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390363AbfKDWJQ (ORCPT ); Mon, 4 Nov 2019 17:09:16 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E55202084D; Mon, 4 Nov 2019 22:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905355; bh=asVhnAg/bI2hyt9+LNgS+5jw0LDtcyGczWuKJbydNgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YyAlpEjWHGb10N/OueKcATWscXx+PdjmEdUMwYtgCqdAnOLUyJZ5Ff6LUcDH++J4D ukwqf1GWRIaja67zY4g7464Kn+p0lcv63RPbuWO8bon04jHq6imRbaU3zG/vlXLO7y M8iZGzlW9tlK7JrA1cCDRcYPXGYHXmELjQTKQSwI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Jiri Kosina Subject: [PATCH 5.3 117/163] HID: fix error message in hid_open_report() Date: Mon, 4 Nov 2019 22:45:07 +0100 Message-Id: <20191104212148.699755550@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michał Mirosław commit b3a81c777dcb093020680490ab970d85e2f6f04f upstream. On HID report descriptor parsing error the code displays bogus pointer instead of error offset (subtracts start=NULL from end). Make the message more useful by displaying correct error offset and include total buffer size for reference. This was carried over from ancient times - "Fixed" commit just promoted the message from DEBUG to ERROR. Cc: stable@vger.kernel.org Fixes: 8c3d52fc393b ("HID: make parser more verbose about parsing errors by default") Signed-off-by: Michał Mirosław Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1139,6 +1139,7 @@ int hid_open_report(struct hid_device *d __u8 *start; __u8 *buf; __u8 *end; + __u8 *next; int ret; static int (*dispatch_type[])(struct hid_parser *parser, struct hid_item *item) = { @@ -1192,7 +1193,8 @@ int hid_open_report(struct hid_device *d device->collection_size = HID_DEFAULT_NUM_COLLECTIONS; ret = -EINVAL; - while ((start = fetch_item(start, end, &item)) != NULL) { + while ((next = fetch_item(start, end, &item)) != NULL) { + start = next; if (item.format != HID_ITEM_FORMAT_SHORT) { hid_err(device, "unexpected long global item\n"); @@ -1230,7 +1232,8 @@ int hid_open_report(struct hid_device *d } } - hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); + hid_err(device, "item fetching failed at offset %u/%u\n", + size - (unsigned int)(end - start), size); err: kfree(parser->collection_stack); alloc_err: