Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4491969ybx; Mon, 4 Nov 2019 14:18:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxdxzSdqJerPivyo7vS5spzn4tklXfTsJWx4RqxpkY4s+JcD85x2+YPKdtfnzvG/bXLxBVA X-Received: by 2002:a50:ea8a:: with SMTP id d10mr4789611edo.97.1572905922614; Mon, 04 Nov 2019 14:18:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905922; cv=none; d=google.com; s=arc-20160816; b=kESSXNXW1UfsRGJLlJfG0tJQLtGB+eXpuR3xQTeqIx6yD9MYROHqGTvuo+wzRZRDok K2RNqiuprGsvMB7YLIk5la9p5yhgomE3uzJgrJchv1msKM3Mp8rhfa2XX0vAP6VkRNf0 ceEiJToxJgTCqAEQgE7xXabU+seOaRoCJtXMsSRyS3gJN8R9yHKWQ/VOVn6YRWd3dbQV aqkOKajlGsQsxE5JhZVZNL/PSoAGl5BdZhf4dwciQEMPW1MXgZGJpfak7CQ5maHfE0yB Zm7Q+vKStiw8Z8pruv0PqHNZYGUMiWUqVDbWoiVBWK230vSID5ZMiL+LAlyrxeEPSeUB ky7g== 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=BBmcisxwuOVJ7slJg4VyD7eRq0PC/I8QtuvmoILj/4M=; b=eOMc0iHjM3D8XBEIccAXpeDUXvqYG7zS4NUE2c566zq4SfRjBDE05ODWAsLZoZiIS/ sqpBgcUhG58fx8uePVvDseQLsMNOGcjbV6hS1kw4h4si1rNQSTCQktehEJpx6AbxH6Fk sKj/cAqx1a80mJoLFJMeTVshlyKslvihMNZYXrurP50ybtgR/nvkaQuFKiKCZaixxyQz AGAmdpU5NbF3fhc5rd33/aClh8+CdyOnDbpr/pcPKNuZcBVFajQqWWYsGKPRKGlil/gA cgyjHkvqiLjaK/HWtSKOoygpwrGdetztPkuOG1YlEXyArycz/QTnY4+cdtWgEB04YxDx a6wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qFVHyA7d; 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 cc4si7553220edb.237.2019.11.04.14.18.18; Mon, 04 Nov 2019 14:18:42 -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=qFVHyA7d; 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 S2389367AbfKDWCi (ORCPT + 99 others); Mon, 4 Nov 2019 17:02:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:60880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388532AbfKDWCb (ORCPT ); Mon, 4 Nov 2019 17:02:31 -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 6AD8B217F4; Mon, 4 Nov 2019 22:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904950; bh=7CsHA9B5hURGTItzScFRdEZtOT/srucqQJMFJXGiboQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qFVHyA7dPa/8BXfxEw+ZK+4c2ybntsM0Qd3o3CP0vrr4axvYT9OgllRt4z875gXxv kJddE88mO4xq+i4N6pmiTb3W2ioGTXBtR/l4KA8qMXYgqdgdDlLlinIqqmH81+OauG jkAQpb9UaYobzIfZ/0IPsaZnTx9IEEG6AvEMa04c= 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 4.19 125/149] HID: fix error message in hid_open_report() Date: Mon, 4 Nov 2019 22:45:18 +0100 Message-Id: <20191104212145.016448337@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212126.090054740@linuxfoundation.org> References: <20191104212126.090054740@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 @@ -975,6 +975,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) = { @@ -1028,7 +1029,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"); @@ -1058,7 +1060,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: