From patchwork Wed May 11 02:23:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 775682 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4B2NGvJ018298 for ; Wed, 11 May 2011 02:23:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753113Ab1EKCXT (ORCPT ); Tue, 10 May 2011 22:23:19 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:59603 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752971Ab1EKCXS (ORCPT ); Tue, 10 May 2011 22:23:18 -0400 Received: by bwz15 with SMTP id 15so66719bwz.19 for ; Tue, 10 May 2011 19:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to:cc :content-type; bh=XPfGFqqVV6iFEDtp+3D19+aciUDyJk8Lm9A4p8+dXE0=; b=Gug8OiAE14u24ikdKylv1z95UD9fhCdZxBes1kZSiV+dyWtyx1k7iOD1llX4cggNGK CGaXPn/bz5zjwMWz3wxei4bU4ZOGEqUcqKrB8opoSYE6djoxwJ8TGxNFYQsVUN0BC4lQ doQ2adGEoDlV/90l7bskf6NbYlpviG8xx3NFk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=Nm0S6U5QnbvtlZ4P2HxI7TkcQHwIINVRwsjoJztIkw1BBtTyVD/AgorasPIRwdWo+C DtN4i+oETf/BvYqhJXQgjg/Mv8v6XK7FpR0MieOmyhvIH39uK14zgQ/ftn4vj3bIn2x5 vNXgW+eRc/zmIgdU4QrRINM87sRcyMC/mn45U= MIME-Version: 1.0 Received: by 10.204.141.14 with SMTP id k14mr1665636bku.37.1305080596108; Tue, 10 May 2011 19:23:16 -0700 (PDT) Received: by 10.204.116.83 with HTTP; Tue, 10 May 2011 19:23:16 -0700 (PDT) Date: Wed, 11 May 2011 10:23:16 +0800 Message-ID: Subject: [PATCH] touchscreen: check kzalloc memory for data first From: Steven Liu To: jy0922.shim@samsung.com Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, dmitry.torokhov@gmail.com, liuqi@thunderst.com Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 11 May 2011 02:23:19 +0000 (UTC) Hi Joonyoung Shim , Can this patch be fixed in? if kzalloc memroy for data was faild, it will multi free data memory space. so check the data memory first, is it kzalloc faild for data, it should goto end and do nothing. Signed-off-by: LiuQi --- drivers/input/touchscreen/atmel_mxt_ts.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) Best Regards Steven Liu -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1039,8 +1039,15 @@ static int __devinit mxt_probe(struct i2c_client *client, return -EINVAL; data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL); + + if(!data){ + dev_err(&client->dev, "Failed to allocate memory\n"); + error = -ENOMEM; + goto err_alloc_data_mem_faild; + } + input_dev = input_allocate_device(); - if (!data || !input_dev) { + if (!input_dev) { dev_err(&client->dev, "Failed to allocate memory\n"); error = -ENOMEM; goto err_free_mem; @@ -1107,9 +1114,10 @@ err_free_irq: free_irq(client->irq, data); err_free_object: kfree(data->object_table); -err_free_mem: input_free_device(input_dev); +err_free_mem: kfree(data); +err_alloc_data_mem_faild: return error; }