Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4497756ybx; Mon, 4 Nov 2019 14:23:53 -0800 (PST) X-Google-Smtp-Source: APXvYqwDIG826SfNt3Lr8x1uiIrxO7qPy/7Xprrro0eMmTaxUU+M/JfnNal5jLSBwEcLHi4zRudR X-Received: by 2002:a17:906:5fd0:: with SMTP id k16mr15412847ejv.243.1572906233198; Mon, 04 Nov 2019 14:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572906233; cv=none; d=google.com; s=arc-20160816; b=LVq9CVL+T6hhzXEg2c8tIq6LYVc7rvCTMVwtwYump2s+3F/o0w2N5ApjHBtKldRLDt 8hXQkc0oPI7aV6b4hho4gQJyVvdcwVcVGuiNcQp3ZzS2Oo2bMh1ed4pTl6BBUfhgAwZK uaAkUqCXkD2skwB/om0sLoSr+JI4NXFXXuwhoWDX0SdQ+gEmQCZOiQbKt4QLrMZhrLLc R/p/mt8625HHEhOEZjV/fNAKgc7totybPSFrvnEYoSy17tXYm1gcE+D7v9xCKqUiGl2F gqj1fYJd6OfLUwmtMmDCHhCQoe9CdStM0GFBlrLndps1V7l/J9XodZi9DfC+c4XzcNU6 sYlw== 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=5HZX28qWsB/zYks2/QnHJoeU2MBkyZJpbCQgDCgEx8s=; b=CTbj3FO4jmJsKdddjwidZG4TZfW8GjQHgfM8wl8z4Ygc9ctKDuclLAh3AHcvHlXhYO YrQ5tHtZJGlb2DQaiqLO7Jy1vhXiHvqGPc4WoZsyqjOYkTd51mW7tQY7/G8r3jCOzdyI 529Qpzi2cXctTMEl0MiLsaomm+RK+BvpM4z1k+H21lotlCUYL9YuJ0tMHYLWApXiZUFc ThJAc8sxZ6XN4gC2TXaSCV3DgGekuC5wCc6dxcUc6NRdfMHidEIdMkZewGRzJW7ttHty Xb0B6CcjbdosEroCtD0ynoINJ0l/3j0uEN2i6aVpEXYZW8/RADsfPcv18qifRGJpsM34 VHoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eyYACyB1; 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 w57si7591375eda.78.2019.11.04.14.23.28; Mon, 04 Nov 2019 14:23:53 -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=eyYACyB1; 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 S2387726AbfKDVze (ORCPT + 99 others); Mon, 4 Nov 2019 16:55:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:50806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387652AbfKDVzb (ORCPT ); Mon, 4 Nov 2019 16:55: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 132CB217F4; Mon, 4 Nov 2019 21:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904530; bh=nG6VPbCohQi6fBlcsnH+qIJ+5t18M1eyrl6miwMHJpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eyYACyB1QMFWX8Sy+5AfcLOwZcwuMoV1uqRgeUnv6WXdUcPsH5DeuRaaM4WRTBjew q96Zvh1hBWJqTFepP7aHlt6iecv7Ub9bhhshwThjxW1i6dQm7vuHNz0TKjGcdtQ66w +Uchc/G0Q5K7gpyfrHwcajdOxHVbQHqa6VrMa1hw= 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.14 77/95] HID: fix error message in hid_open_report() Date: Mon, 4 Nov 2019 22:45:15 +0100 Message-Id: <20191104212118.836009009@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212038.056365853@linuxfoundation.org> References: <20191104212038.056365853@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 @@ -979,6 +979,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) = { @@ -1032,7 +1033,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"); @@ -1061,7 +1063,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: vfree(parser); hid_close_report(device);