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: 9843 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4B52B23E16 for ; Thu, 5 Jul 2012 13:06:39 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 0DAAEA182CE for ; Thu, 5 Jul 2012 13:06:38 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id z12so7960629ghb.11 for ; Thu, 05 Jul 2012 06:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=qLFqq/f+qBOsIJnXE1fUjb2khAfCSexPKeL3P1pNLoA=; b=mWJCOiIgMIWrZ/U4X+NII3OeBjLdn754/R2tLGoU+8umFWmMAkunhIDqrXWhPxu/S4 TnaEXFErldHHrvcrZ8nNfnIcE4SYVBmAQKf7BLy5EzcEqNq70r2fEFrhFE18N0jHTUvH syP3NynjPXZqrMMPMfLCCrtnn8V0ESkuXCiEdV9UZEXYZTNH3imK6LJb1zasnSgrqyKz YsGKW46qMifqGie7fOVbE/octmxIrCROxDmsaR5JQRBsJpXClp9gFBQ2xI4yUw1bTioX 5X8TMQuNd86HN2Lxhr92O6dd3dlkZiav+ouIUxRlxLasSjogaV81uNdl3qfBqq8V8Ing vRyQ== Received: by 10.50.195.234 with SMTP id ih10mr14190360igc.0.1341493598520; Thu, 05 Jul 2012 06:06:38 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp65208ibb; Thu, 5 Jul 2012 06:06:37 -0700 (PDT) Received: by 10.217.1.202 with SMTP id n52mr3287070wes.21.1341493597099; Thu, 05 Jul 2012 06:06:37 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx.google.com with ESMTPS id cw6si21360510wib.12.2012.07.05.06.06.36 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 06:06:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.172; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by wibhm11 with SMTP id hm11so5144759wib.13 for ; Thu, 05 Jul 2012 06:06:36 -0700 (PDT) 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 Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, Lee Jones 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: ALoCoQnQ6WcE0/N5veoH3Pefk7pbFNSYmrtJmE9tAPYp69o1euCCESSJVRmAsTsG6rFZUz4OxKs7 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;