From patchwork Thu Feb 7 14:17:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Meerwald-Stadler X-Patchwork-Id: 2111181 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 87964DFB7B for ; Thu, 7 Feb 2013 14:18:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758656Ab3BGOSG (ORCPT ); Thu, 7 Feb 2013 09:18:06 -0500 Received: from ns.pmeerw.net ([87.118.82.44]:47054 "EHLO pmeerw.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758666Ab3BGOSD (ORCPT ); Thu, 7 Feb 2013 09:18:03 -0500 Received: from localhost.localdomain (unknown [195.70.114.118]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: pmeerw) by pmeerw.net (Postfix) with ESMTPSA id E8631C50286; Thu, 7 Feb 2013 15:18:00 +0100 (CET) From: Peter Meerwald To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, djkurtz@chromium.org, y0922.shim@samsung.com, Peter Meerwald Subject: [PATCH 7/7] input: atmel_mxt_ts: check if all config pdata has been written to object table Date: Thu, 7 Feb 2013 15:17:48 +0100 Message-Id: <1360246668-2291-8-git-send-email-pmeerw@pmeerw.net> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1360246668-2291-1-git-send-email-pmeerw@pmeerw.net> References: <1360246668-2291-1-git-send-email-pmeerw@pmeerw.net> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Peter Meerwald firmware revisions may introduce or alter device objects; error out if there is an inconsistency (otherwise the device may silently fail) mxt_platform_data.config is dangerous because the data must match the device object exactly; if the order or size changes, or if device object disappear, garbage is written to the device Signed-off-by: Peter Meerwald --- drivers/input/touchscreen/atmel_mxt_ts.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 7ade272..b85fb30 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -636,6 +636,11 @@ static int mxt_check_reg_init(struct mxt_data *data) index += size; } + if (index != pdata->config_length) { + dev_err(dev, "Config data inconsistent with device objects!\n"); + return -EINVAL; + } + return 0; }