From patchwork Wed May 11 02:45:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 775722 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4B2joGE026092 for ; Wed, 11 May 2011 02:45:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753430Ab1EKCpt (ORCPT ); Tue, 10 May 2011 22:45:49 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:58240 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752859Ab1EKCps (ORCPT ); Tue, 10 May 2011 22:45:48 -0400 Received: by bwz15 with SMTP id 15so76263bwz.19 for ; Tue, 10 May 2011 19:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=QwqFveL9F/4pjc7QCZcD9iPC/lqNa6J2Q1t3Q4xRZ2I=; b=N/QkD0BQ+ne0RVhkDmI5JO+7yM3si8NmJu/V8n0od3S73iKjaRjn/qJBHlirC+6OEu HJnc9loszz7lPhQIUWDpQCWu/+ZY/4IZsoQMHtG3fGMySiHJ5MVQVpXnoCcgzZg/uVY6 VDlGRLcoahWOK7OYuwDJGodl368kHDBESJ4C8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=xfvQv6Wxn/by/uaS8d41UQo+RcwD9Eo5uUAO2SrteqFQ7GeQcZ7Sti96eXDsO3blO0 ggyLoonBEic1LzVzrKBLQgZTIH1Ie7rhofeo6j6VZ5scWfl0tzszqn5MXyzQlBk9zrLW gSZU+E4qw6TKZwQxpvoZNjpKqRAkYaSTPTkU0= MIME-Version: 1.0 Received: by 10.204.11.22 with SMTP id r22mr156562bkr.172.1305081946781; Tue, 10 May 2011 19:45:46 -0700 (PDT) Received: by 10.204.116.83 with HTTP; Tue, 10 May 2011 19:45:46 -0700 (PDT) In-Reply-To: References: Date: Wed, 11 May 2011 10:45:46 +0800 Message-ID: Subject: Re: [PATCH] touchscreen: check kzalloc memory for data first From: Steven Liu To: jy0922.shim@samsung.com, 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 (demeter1.kernel.org [140.211.167.41]); Wed, 11 May 2011 02:45:50 +0000 (UTC) fixed the code style new patch is 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 | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) -- -- 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,14 @@ 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 +1113,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; }