From patchwork Sun Aug 4 16:04:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishka Dasgupta X-Patchwork-Id: 11074791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D11A214DB for ; Sun, 4 Aug 2019 16:04:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B041B287F5 for ; Sun, 4 Aug 2019 16:04:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F3BF28800; Sun, 4 Aug 2019 16:04:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 554CD287F5 for ; Sun, 4 Aug 2019 16:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Jl7McrdAUGMDj37xLBNNxGHIEZsYLacCkEuPM40M8qQ=; b=Ns3VE6nT/RwioR RG7ebiTISYeJgE04WCiaQJKwgU3yVz3ecGOhaqIWFilG7mJQ/uB5tz8uTCJEB6jZ/nrYBW/2wMHDc G54dbG6LK+b8AVLIt3MI8pHvfP2XWOoLkN5E3yPAqtgC334yGvV1h7N1uuI4H/uhW/8ElswLJXSEd jLzJI8Gb0fFsPHG5rBVghvP4BLTzJLB3PSWwCuWWZoZlQ1nYO2uNOQuHdUIlsMOFoB8aeP32KrYGS Aq02nn4bIUAtQ7/6i312ZObvoT3CfwbcPOmhAzfRm5nJEq6TUbU+vtL9bkPs7aCAZudx9uZA1JH2v MA2yz2qhaDyEMMvhss6A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1huIzt-000050-TB; Sun, 04 Aug 2019 16:04:37 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1huIzq-0008Vy-UI for linux-arm-kernel@lists.infradead.org; Sun, 04 Aug 2019 16:04:36 +0000 Received: by mail-pg1-x541.google.com with SMTP id n190so3283310pgn.0 for ; Sun, 04 Aug 2019 09:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=43+wBAA2pYCZyIeE6dblgNpeldlqw4UsjWWmEq3JFkQ=; b=MNB/Mc92mGLyuhVsZap7ySAwBC6u9/2UU+v246vUn8jld4GTJtPBdEK/sS4jqDUALx ASGO3QxSSTMfen5a4818hqHKc6dGWuxarFx4xVAR37oOi3z8C6DwKf3cpZXKhDzcZzDT ARu26iZVW+gzOfNZZ9Id3tcZBBzBwANnqVKwf8VzC5/yECvRSodP2CfPxpjUyEwuSPxC qH90LTTJ6KOYUienovhJSPBFDDWqgKPSz1JCYRZq/rovUJDq6RyBecXXng5tZP2ocKyN hfLDw1Dxmy84XUppiFSG/z4ANSf/CaaFsXaIFTK2flreppmFfwGRRCzJxKNQuDlWqeJP okjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=43+wBAA2pYCZyIeE6dblgNpeldlqw4UsjWWmEq3JFkQ=; b=l+eHa5YgE02wcDA8AmQYoK50atKirolAiqd9I/Hz0ntCyIcOPLsqe/gaOsMiR1lbdO DeENE7DhqQIGX5zkdZTZSrXXDBteLqcahIJ+wEef7DEvv1goYngYwTX2+TJNKh7GxV7Y r7RR61wFVBtJo1CnsmvGoxwNsITC69YrT5Fpqeg0ZZKq/KLpP+LuIb3JxI+UNmmBlrLq OStBoDzKbklbk1pTT+3ZXL5m1HFNPkM0rxRXBK34DFnJJt9iXvlz8x0WPonHx+OWmIEH ntf8BSCkjzRANIapedtOrOhGOLcsgn8LNAIawXJ62RXpjrlftlGPgS8mOXpuTyihVwPH GzJQ== X-Gm-Message-State: APjAAAULNh8pGRnmWL1ZcbbAg9myiLA3DSdJDtzXE9YGtLOCFuno54ZS 7DZ+d53QE7cSCulpBB4dBL/2zpo/MCM= X-Google-Smtp-Source: APXvYqyoNpL7JNr6fzQGvbgLfKgJsIZcPfbrRAGknNTrjrqkxFtSsE80PHNU91LWByI9gkjdaETv6w== X-Received: by 2002:a17:90a:fa12:: with SMTP id cm18mr13985647pjb.137.1564934674142; Sun, 04 Aug 2019 09:04:34 -0700 (PDT) Received: from localhost.localdomain ([122.163.105.8]) by smtp.gmail.com with ESMTPSA id c8sm9505686pjq.2.2019.08.04.09.04.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 04 Aug 2019 09:04:33 -0700 (PDT) From: Nishka Dasgupta To: linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-imx@nxp.com, s.hauer@pengutronix.de, kernel@pengutronix.de, stefan@agner.ch, shawnguo@kernel.org, festevam@gmail.com, aisheng.dong@nxp.com Subject: [PATCH] pinctrl: freescale: mxs: Add of_node_put() before return Date: Sun, 4 Aug 2019 21:34:20 +0530 Message-Id: <20190804160420.5309-1-nishkadg.linux@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190804_090434_976636_6439107A X-CRM114-Status: GOOD ( 10.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nishka Dasgupta Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Each iteration of for_each_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return in three places. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta --- drivers/pinctrl/freescale/pinctrl-mxs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c index 641b3088876f..735cedd0958a 100644 --- a/drivers/pinctrl/freescale/pinctrl-mxs.c +++ b/drivers/pinctrl/freescale/pinctrl-mxs.c @@ -488,8 +488,10 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, if (of_property_read_u32(child, "reg", &val)) { ret = mxs_pinctrl_parse_group(pdev, child, idxg++, NULL); - if (ret) + if (ret) { + of_node_put(child); return ret; + } continue; } @@ -499,15 +501,19 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, f->ngroups, sizeof(*f->groups), GFP_KERNEL); - if (!f->groups) + if (!f->groups) { + of_node_put(child); return -ENOMEM; + } fn = child->name; i = 0; } ret = mxs_pinctrl_parse_group(pdev, child, idxg++, &f->groups[i++]); - if (ret) + if (ret) { + of_node_put(child); return ret; + } } return 0;