From patchwork Tue Dec 4 15:27:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1838861 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B9CF23FCA5 for ; Tue, 4 Dec 2012 15:31:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753470Ab2LDP2V (ORCPT ); Tue, 4 Dec 2012 10:28:21 -0500 Received: from mail-wg0-f46.google.com ([74.125.82.46]:50038 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752932Ab2LDP2S (ORCPT ); Tue, 4 Dec 2012 10:28:18 -0500 Received: by mail-wg0-f46.google.com with SMTP id dr13so2395288wgb.1 for ; Tue, 04 Dec 2012 07:28:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=b2Pb2Rl4zyWn4ZijRbk0SH6Dt2Et+JvBWc4JCIq5Rdo=; b=QwufRUJASs0Zw4S8VYeMItv8vRBzN0GkUKU0tUWYLVTN3/kSYrnsqXBq8KPCYzDMIK vdkCtC5cAgOEMMNOGnCzregmU8SVNgdA0EPsZbLuCREXShcxruLf14yc8cJFb+tcD3ra 9M4voz00gAHrFeMcELA7gpL1Tg2Jvlg/izaQVejGFaBMXEAMftqlW/l3ViFlrzRSOMTi 5O/oKEz5K258lfF7ojJhViF3RXhQmjX38b+VrJkLLzJufJoXscgQc6gu5MWlbpkpeSeR 4VacC4+zSHCXoN4ToeF1pQynWPHkQsPrEMapsr6fE1e/Q14fDjtjluMQ4qLo/+3rPnQE MLiA== Received: by 10.180.95.169 with SMTP id dl9mr5094085wib.20.1354634896608; Tue, 04 Dec 2012 07:28:16 -0800 (PST) Received: from localhost.localdomain.com (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id p3sm15443846wic.8.2012.12.04.07.28.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Dec 2012 07:28:15 -0800 (PST) From: Benjamin Tissoires To: Benjamin Tissoires , Jiri Kosina , Jean Delvare , linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/14] HID: i2c-hid: fix memory corruption due to missing hid declaration Date: Tue, 4 Dec 2012 16:27:43 +0100 Message-Id: <1354634875-5182-3-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.8.0.1 In-Reply-To: <1354634875-5182-1-git-send-email-benjamin.tissoires@gmail.com> References: <1354634875-5182-1-git-send-email-benjamin.tissoires@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org HID descriptors contains 4 bytes of reserved field. The previous implementation was overriding the next fields in struct i2c_hid. Signed-off-by: Benjamin Tissoires --- drivers/hid/i2c-hid/i2c-hid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 0fbb229..ad771a7 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -68,6 +68,7 @@ struct i2c_hid_desc { __le16 wVendorID; __le16 wProductID; __le16 wVersionID; + __le32 reserved; } __packed; struct i2c_hid_cmd { @@ -778,7 +779,7 @@ static int __devinit i2c_hid_fetch_hid_descriptor(struct i2c_hid *ihid) } dsize = le16_to_cpu(hdesc->wHIDDescLength); - if (!dsize || dsize > HID_MAX_DESCRIPTOR_SIZE) { + if (!dsize || dsize > sizeof(struct i2c_hid_desc)) { dev_err(&client->dev, "weird size of HID descriptor (%u)\n", dsize); return -ENODEV;