Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp2011396pxa; Sat, 29 Aug 2020 10:58:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMayI1/3M+0LY9SfZuPS/mmf84760Mg7mVP27rlQnEYf8/LaLUwwILZCQwJGC+JgRJZAYE X-Received: by 2002:a50:8e52:: with SMTP id 18mr4363993edx.28.1598723898340; Sat, 29 Aug 2020 10:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598723898; cv=none; d=google.com; s=arc-20160816; b=0n1TGhBIsO4qxpP13qCQcid5xrQGRDEC/lWWC10h1kDRcER+D/91Hei+GtuhVXAEq8 vyXU2ro0VlmkC2Wlq9/6dCEN+2+66/g9wHC9Zh25k8+cbxdpV/aoZ2eo5il0YqnMkvII tDlNj1Z1O15/Bb4Ey8Ayx1N07Cak0hPcTnKl8uaX2apGAPSI9deZYbHLVuHyVeKPup6i zkh/7Grfw2PZiJ0NzK+FMlw2acwYQpyvxhJggh/xP4G31xdRy72I1SBvcoDQ5tPCscWS Bztq3IJBLxSCDk8ZKVyuEgXq0inOTCw3myeSojnqqvgIxnlpfyOb8EodSSC4cHGo24Li 8ylA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=nXrk/kbkqy9ClgLwV0Wr/6W8seRn97oLX3UsuxPWEoY=; b=DRGGDmxdc94mcIwPOF98xT8CRxWHCEiny6kW+wQZXPxVug5PUoD3+bwPszV7d6G1sT NWt6Y8i7xiOywe1ykNr+dhiGU9NX/YMw4RzzU8dvJCwPSBJuq2sM/tIYkxJkdiNnRubL P9UKWMz94wzy9RIvPPMMpo/F5fWWUbRpyOoWteR4SXov/cSmNbl71KfrG1RxvGJ9yO2z neLHX+ZtaFKyi/8lWgUCONyrlabKNKk9q8D+jlnUH/ec5RJgHKZRzPWYQk/0YxpMHlCi 93WdAeCt6dNcGr0Zhs3q9hTe85fe5Yw+b9t0ei82rDCMMOhiW6SLuNk2XeC4iDLz7dVg MwQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nHvExVGc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t27si2144382ejf.672.2020.08.29.10.57.53; Sat, 29 Aug 2020 10:58:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nHvExVGc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728370AbgH2R5N (ORCPT + 99 others); Sat, 29 Aug 2020 13:57:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728244AbgH2R5K (ORCPT ); Sat, 29 Aug 2020 13:57:10 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8024C061236; Sat, 29 Aug 2020 10:57:09 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id ds1so1023390pjb.1; Sat, 29 Aug 2020 10:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=nXrk/kbkqy9ClgLwV0Wr/6W8seRn97oLX3UsuxPWEoY=; b=nHvExVGcx1v5QIMuNToDfBdw5r05ACuQOvQVL0p0Mv7PF5Dv7tkS0/hatJ5fvM7Xe3 2/FqOoQTZ12UciQ1z9PpbYlxgsYqOVHrM6OWCuaq5ic56dZVeMCSDk2TxN7ZtXEsVQjx lD7JOzPS865iRr7U/qypbQwlE9ZiSLukddyuj+cNj7BeiyoXN01+J9s76jAqkT3fFm3S Ogu1na4EKzTVGBQ02b3UHuw/NvWTA2NUgIq81VLOCCHRSva9uD0p+ZrNgxrSAAAcTLPi XkGGcSxok9dAtE0wqyXC2M+wdOcLvsmc1wJ2aKu/iOqh5GYqFnXL/KdMHJ9KfkltZVPS fKVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=nXrk/kbkqy9ClgLwV0Wr/6W8seRn97oLX3UsuxPWEoY=; b=GrFRkInhgzJ5YtNL08UB8yTbIdoa04kxV/RLgKgybqSTZ2DFrtpaXwMQfmxMQWntgR 3Q/0yA1CSa62r73vve9vQ/tI5PzIeb5jPJJiNcKO3y/42wJDa9Qj2PA0It5xlL9QSyLw aNmp0sb5g8F2iAtsbce/dY9zAeteCNMV/A3E9zHVeGdMKATMlRO6bgjKKgR38T0s/nKj T8v2/J1J64LqvtV+ofGsG+7pEbdfAXaeu9/27xwqFMqQnpU4bSrGV5kayuo8Mzu5f4Nh p2PAJ6eddNH+tBQ00qAydEV10LdCjF5/ijt8yRILgKOQqoIZoWIbO1BW9rWW4VOP/dh5 P99A== X-Gm-Message-State: AOAM5321n2P8R+nRRmGhWcBoXpeus0jg8u1oDB7cAsKja0cgz1Yc8PBB d/XbRHZ0V4/6ZNtfth1lv1w48xaxmXZDSlRK X-Received: by 2002:a17:902:8d82:: with SMTP id v2mr3404174plo.180.1598723829381; Sat, 29 Aug 2020 10:57:09 -0700 (PDT) Received: from Kaladin ([49.207.221.164]) by smtp.gmail.com with ESMTPSA id j13sm3254207pfn.166.2020.08.29.10.57.06 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 29 Aug 2020 10:57:08 -0700 (PDT) Date: Sat, 29 Aug 2020 23:27:04 +0530 From: Sumera Priyadarsini To: linus.walleij@linaro.org Cc: mturquette@baylibre.com, sboyd@kernel.org, Julia.Lawall@lip6.fr, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: versatile: Add of_node_put() before return statement Message-ID: <20200829175704.GA10998@Kaladin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Every iteration of for_each_available_child_of_node() decrements the reference count of the previous node, however when control is transferred from the middle of the loop, as in the case of a return or break or goto, there is no decrement thus ultimately resulting in a memory leak. Fix a potential memory leak in clk-impd1.c by inserting of_node_put() before a return statement. Issue found with Coccinelle. Signed-off-by: Sumera Priyadarsini --- drivers/clk/versatile/clk-impd1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/versatile/clk-impd1.c b/drivers/clk/versatile/clk-impd1.c index ca798249544d..85c395df9c00 100644 --- a/drivers/clk/versatile/clk-impd1.c +++ b/drivers/clk/versatile/clk-impd1.c @@ -109,8 +109,10 @@ static int integrator_impd1_clk_probe(struct platform_device *pdev) for_each_available_child_of_node(np, child) { ret = integrator_impd1_clk_spawn(dev, np, child); - if (ret) + if (ret) { + of_node_put(child); break; + } } return ret; -- 2.17.1