From patchwork Wed Jul 3 13:12:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 2816911 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 89CE39F3EB for ; Wed, 3 Jul 2013 13:13:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B5F7201B5 for ; Wed, 3 Jul 2013 13:13:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BD9C201B3 for ; Wed, 3 Jul 2013 13:13:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756075Ab3GCNNQ (ORCPT ); Wed, 3 Jul 2013 09:13:16 -0400 Received: from relay-s04-hub004.domainlocalhost.com ([74.115.207.103]:54867 "EHLO relay-S04-HUB004.domainlocalhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755484Ab3GCNNP convert rfc822-to-8bit (ORCPT ); Wed, 3 Jul 2013 09:13:15 -0400 Received: from [172.24.3.157] (10.30.12.164) by smtp04.sherweb2010.com (10.30.12.204) with Microsoft SMTP Server (TLS) id 14.2.342.3; Wed, 3 Jul 2013 09:13:13 -0400 Message-ID: <51D42350.10504@cypress.com> Date: Wed, 3 Jul 2013 16:12:48 +0300 From: Ferruh Yigit Organization: Cypress User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: Dan Carpenter CC: Javier Martinez Canillas , Dmitry Torokhov , , Subject: Re: [patch 3/3] Input: cyttsp4 - leak on error path in probe() References: <20130702214455.GC1598@elgon.mountain> In-Reply-To: <20130702214455.GC1598@elgon.mountain> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 07/03/2013 12:44 AM, Dan Carpenter wrote: > We leak "cd" if the cd->xfer_buf allocation fails. It was weird to > "goto error_gpio_irq" so I changed the label name. (Label names should > reflect the label location not the goto location otherwise you get an > "all roads lead to Rome problem"). > > Signed-off-by: Dan Carpenter > xfer_buf still may not be freed, I propose following one instead: From: Ferruh Yigit Date: Wed, 3 Jul 2013 15:59:54 +0300 Subject: [PATCH] Input: cyttsp4 - free xfer_buf in error path Label for xfer_buf error is wrong and causing mem leak for cd. Updated label for xfer_buf alloc failure and add kfree for xfer_buf Signed-off-by: Ferruh Yigit --- drivers/input/touchscreen/cyttsp4_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) /* Initialize device info */ @@ -2127,6 +2127,8 @@ error_request_irq: cd->cpdata->init(cd->cpdata, 0, dev); dev_set_drvdata(dev, NULL); error_gpio_irq: + kfree(cd->xfer_buf); +error_alloc_xfer: kfree(cd); error_alloc_data: error_no_pdata: -- 1.7.9.5 This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message. -- 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/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 69c9cff..219e32d 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -2034,7 +2034,7 @@ struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, if (!cd->xfer_buf) { dev_err(dev, "%s: Error, kzalloc\n", __func__); rc = -ENOMEM; - goto error_alloc_data; + goto error_alloc_xfer; }