From patchwork Thu Jul 5 13:06:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 1160781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 9A052DFB7C for ; Thu, 5 Jul 2012 13:39:13 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmmBP-0006Ed-9Z; Thu, 05 Jul 2012 13:33:23 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SmllW-0008FS-QX for linux-arm-kernel@lists.infradead.org; Thu, 05 Jul 2012 13:06:40 +0000 Received: by wgbds1 with SMTP id ds1so5732325wgb.18 for ; Thu, 05 Jul 2012 06:06:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=qLFqq/f+qBOsIJnXE1fUjb2khAfCSexPKeL3P1pNLoA=; b=cke7KDbALmRTnomwqbYDUx1YE13NGGrHtIS9ENy4lu7bm3YfbWHXhQSOYZGmKbT0Ir XY4C6oW7FI8PjH1g1YDtKReedmV3dHiwpBWFLRlBrsMVYKIXsK6NZzxNAXsHrQvR+dxJ Fejpo2D48BUbfRagz/XgWpATurO+GD+U1ZAyjkIT4/L9cbrooron1oNpt5TdzPOTlWML kVU6/YxNsL4AhfgGQNFXkXWT3jh7PvFS66srD/YE0HrJkdT6MBCCj7Tq7813TrmLhkqt aDGJialUSac5mf3UK0zC634fx8WSBNBbcB9j3ikbJIQNDi1yun4SV5tSDGpjlCP6JFAM y+kg== Received: by 10.180.100.136 with SMTP id ey8mr14103836wib.15.1341493596544; Thu, 05 Jul 2012 06:06:36 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id k8sm76767305wia.6.2012.07.05.06.06.34 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 06:06:35 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] pinctrl: pinctrl-nomadik: Fix possible memory leak Date: Thu, 5 Jul 2012 14:06:04 +0100 Message-Id: <1341493572-29735-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341493572-29735-1-git-send-email-lee.jones@linaro.org> References: <1341493572-29735-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkAPKQKyHN8fuAzC0Uoadjt2Ozoi910TowJadyzWCv80UagFsYtTvfA7pH2O+UNtRI8vSIt X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: STEricsson_nomadik_linux@list.st.com, Lee Jones , linus.walleij@stericsson.com, arnd@arndb.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If the Nomadik Pin Control driver is continuously bound and unbound from the same device a number of times the kzalloc() will leak memory. Replacing it with devm_kzalloc() will ensure memory is freed automatically in the event of failure and unbinding. Signed-off-by: Lee Jones --- drivers/pinctrl/pinctrl-nomadik.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c index 3e7e47d..af0389f 100644 --- a/drivers/pinctrl/pinctrl-nomadik.c +++ b/drivers/pinctrl/pinctrl-nomadik.c @@ -1194,7 +1194,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) } if (np) { - pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); + pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM;