From patchwork Thu May 2 16:03:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 2512681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id BC587DF215 for ; Thu, 2 May 2013 16:03:59 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UXvz5-0003WF-9u; Thu, 02 May 2013 16:03:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UXvz2-0003e3-Ms; Thu, 02 May 2013 16:03:48 +0000 Received: from smtp27.mail.ru ([94.100.176.180]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UXvyy-0003dd-Of for linux-arm-kernel@lists.infradead.org; Thu, 02 May 2013 16:03:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=g4qzTf8cEluBM1qM0jnuVOdI6cGF3BZSXwEgmK4hZTM=; b=iBCtTT12WSjFEoaqmTycTkrhZbQiswgyivvUjrle0TUzvCZ/EiZ7axHRcjxKuWEf78OO9m99jq48N62QAZtZwzfl0tEPOOdyNG1NTn+YCd+iOyqF9pgM5SNIID/Teq3qSdJHTtUYzhtDVs2nnkKsGFvwZNMDhRY+7h15+EuO1lQ=; Received: from [188.134.40.128] (port=62181 helo=shc.zet) by smtp27.mail.ru with esmtpa (envelope-from ) id 1UXvyZ-0006e5-Hz; Thu, 02 May 2013 20:03:19 +0400 From: Alexander Shiyan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: OMAP-USB: Fix possible memory leak Date: Thu, 2 May 2013 20:03:16 +0400 Message-Id: <1367510596-27780-1-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.1.5 X-Spam: Not detected X-Mras: Ok X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130502_120345_260336_D6ECB2FA X-CRM114-Status: UNSURE ( 8.56 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (shc_work[at]mail.ru) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [94.100.176.180 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Alexander Shiyan , Arnd Bergmann , Tony Lindgren , linux-usb@vger.kernel.org, Felipe Balbi , linux-omap@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Signed-off-by: Alexander Shiyan --- arch/arm/mach-omap2/usb-host.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c index aa27d7f..8d17a0d 100644 --- a/arch/arm/mach-omap2/usb-host.c +++ b/arch/arm/mach-omap2/usb-host.c @@ -570,8 +570,10 @@ static int usbhs_add_regulator(char *name, char *dev_id, char *dev_supply, supplies->dev_name = dev_id; reg_data = kzalloc(sizeof(*reg_data), GFP_KERNEL); - if (!reg_data) + if (!reg_data) { + kfree(supplies); return -ENOMEM; + } reg_data->constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS; reg_data->consumer_supplies = supplies; @@ -579,8 +581,11 @@ static int usbhs_add_regulator(char *name, char *dev_id, char *dev_supply, config = kmemdup(&hsusb_reg_config, sizeof(hsusb_reg_config), GFP_KERNEL); - if (!config) + if (!config) { + kfree(supplies); + kfree(reg_data); return -ENOMEM; + } config->supply_name = name; config->gpio = gpio; @@ -589,17 +594,25 @@ static int usbhs_add_regulator(char *name, char *dev_id, char *dev_supply, /* create a regulator device */ pdev = kzalloc(sizeof(*pdev), GFP_KERNEL); - if (!pdev) + if (!pdev) { + kfree(supplies); + kfree(reg_data); + kfree(config); return -ENOMEM; + } pdev->id = PLATFORM_DEVID_AUTO; pdev->name = reg_name; pdev->dev.platform_data = config; ret = platform_device_register(pdev); - if (ret) + if (ret) { pr_err("%s: Failed registering regulator %s for %s\n", __func__, name, dev_id); + kfree(supplies); + kfree(reg_data); + kfree(config); + } return ret; }