From patchwork Tue Jul 16 05:59:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishka Dasgupta X-Patchwork-Id: 11045281 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 A296514DB for ; Tue, 16 Jul 2019 05:59:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83F1328587 for ; Tue, 16 Jul 2019 05:59:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 755D0285A5; Tue, 16 Jul 2019 05:59:32 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 2D1BA28587 for ; Tue, 16 Jul 2019 05:59:32 +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=35eIJI9halIv2J3JV5/nGisKMLhlKJcVFsIGpcOFqYc=; b=WJkfeOCSDG/1vY diWQl471x5r3QRSt55qgbKD0wvVYPDor4uek9qvOC36ZSikcWr07rDcVWdLvmHIFQygJeks8sMQ4y P5WYTQsxv2VFiQoNwvmKCYWBZltWXuM4QuIRPsdveFfgTxvS8j5fywTW6YiR/71ie30BvGTjF6u9B 9ZIX6Ug2NrepDNmLIvtYo4mfv7EazYxi9+RkJUAdJFXjLW4zwycFjTVVJr+KKaTFt0U5ECsHAqxqT xfyofvWHvzcVFfPbez9uCeL/q3915VQyxUzAdQk7XpEg+QJQA6tj/aHBTc0WxJZenyFNR+74KA/YJ VbUpmT6UPCSADDUbDA3Q==; 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 1hnGUt-0000aR-2Y; Tue, 16 Jul 2019 05:59:31 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hnGUm-0000Wb-Gj; Tue, 16 Jul 2019 05:59:26 +0000 Received: by mail-pl1-x641.google.com with SMTP id y8so9505455plr.12; Mon, 15 Jul 2019 22:59:24 -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=6l7dCx5edcO6RwvaAinlu+M2qmX8TDyHV2A8jZAyY8Q=; b=i92Tmb+Bal3+8XJqpnTg9inAk6FNoZv4I/FihJEuFZXhnG0D0D4hIXa94lhe2KJk8k rvezLDbCgyNbFMWBT8O/kz7NRM0+NvzV+dK9jHUq84WKoH9MmXv0O9dS6FtrjrQEMBNv r3JTgsWg+opPqpMkWhrVmE/J7WoAa20OaMig+ySUDxe8JiPwq4Iu+IGE/F5Dvyhk6ftN RQhS2Mr6EX2d/Sbh0124BIKBWJzqR6ixjL1+mqT7z3rTZCIlhPfFcnM39luo8HWToCD/ wGWVfxRQIuUCUniBGYzLSCEx0T7prZ/sn3uy2isSCd1OiORZTLi/S2stcMv6OYx6DY5V 8LDg== 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=6l7dCx5edcO6RwvaAinlu+M2qmX8TDyHV2A8jZAyY8Q=; b=VvbBZ+456iRw7qLb3HMSG4Vo0VQ9dc/JhiWIjN7rCRJOfCkhqLBQUb3Hu+SNyfrYcX EfKmfiuTDrGyW3YmXgABvUF7POZkZnmZltdDGyPNMNkI5PANQZC+95L477rUXC6SaR6C Tf4P4/L7KNWSekvTDmjvPpB/NjuQ1YGfd1jR9XGNKHhN/N0xAIkMcTl5epG2VgzY5hb/ 831BWsXfxgPmnk2qvZM7IxDRKFnXDz0HlvrSgvcBDp3xuq0oTWO5rXOP0J58vslqQKlE EBJUtx1hyajp3OmH2NK290p3P2dk8o2dtDM/+NybFjz0KSIMg3XuiBqvS+13qQvIgXbB XS3A== X-Gm-Message-State: APjAAAWXN5TLt9A4vLzX96VWV5je1ln1c76lJnQx1f8aOi3+sQ1bZlPd eCU0SNhHKzf99ke0BrBbNbQ= X-Google-Smtp-Source: APXvYqwCf6KtHt2GyDgvCvteTRTOTBdHkHuk8xPTjXlosefuw+fShIhw1w8zMJCW1TlCUQJEM1N2DA== X-Received: by 2002:a17:902:e512:: with SMTP id ck18mr31355635plb.53.1563256763728; Mon, 15 Jul 2019 22:59:23 -0700 (PDT) Received: from localhost.localdomain ([110.227.64.207]) by smtp.gmail.com with ESMTPSA id w14sm20801735pfn.47.2019.07.15.22.59.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 22:59:23 -0700 (PDT) From: Nishka Dasgupta To: gregkh@linuxfoundation.org, matthias.bgg@gmail.com, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH] staging: mt7621-pinctrl: Add of_node_put() before return Date: Tue, 16 Jul 2019 11:29:08 +0530 Message-Id: <20190716055908.3183-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-20190715_225924_867867_FB94557E X-CRM114-Status: UNSURE ( 9.43 ) X-CRM114-Notice: Please train this message. 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_compatible_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. Add an of_node_put before the return. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 9b52d44abef1..d0f06790d38f 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -358,12 +358,15 @@ static int rt2880_pinmux_probe(struct platform_device *pdev) gpiobase = of_get_property(np, "ralink,gpio-base", NULL); if (!ngpio || !gpiobase) { dev_err(&pdev->dev, "failed to load chip info\n"); + of_node_put(np); return -EINVAL; } range = devm_kzalloc(p->dev, sizeof(*range), GFP_KERNEL); - if (!range) + if (!range) { + of_node_put(np); return -ENOMEM; + } range->name = "pio"; range->npins = __be32_to_cpu(*ngpio); range->base = __be32_to_cpu(*gpiobase);