Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1096687pxy; Thu, 22 Apr 2021 23:26:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJMOSThhr0zwSItEmF8oAS4274P8GUdTi1dryEDAY6ygX2d7nwnKd62eay6ZAcFYT4RREG X-Received: by 2002:a62:dd53:0:b029:25f:ba3c:9cbe with SMTP id w80-20020a62dd530000b029025fba3c9cbemr2645658pff.64.1619159175010; Thu, 22 Apr 2021 23:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619159175; cv=none; d=google.com; s=arc-20160816; b=I/IGxZ2tiusyayj9hyl+iicvkKvJpDc7nsdfVaIRv4Pz4tgudI3m/QWGAUGS/GdG+l SK1mRKiWxRrw7b1pdsk28BFMJn2LZMrJmXybNqF+jwJ2LfjSR7mJhTSPCLcPCLnjoEow mgu1B9arL6urNeGnSKhF8Mjbl2VDhirhXA90O2u9aukyM3p5hK7IRG5VcZCK5c2KiKGx lwgR34/yRITaHG6i1ItHBgAFwg1Td2gH9MOBUKw5+7uo8RbGTACWbp8HTfom16lXTTFj /DRZzTXQHHiL5IbKUN6FYGFIA5Es8ivhO9AWXglCnkf4I1YbXOlw/4cTOV/DavV5JeC2 /JrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+ws1tMbCoROXJQIz8r29q0jjXjZXBe9ysl8/NuI90ns=; b=NhcYglAdcBH4Q0YGtonBvpAT+W0p+eqIt72+8Jckv+dy4F+29InMGCt/+2BJvzqc2f hg4P6oEL5hEN27Z6X0ek+iZNantIoGjP5ITo2GsuZLyEE88Gm7Z+Hqq+oZVCTWygd+ox gp0YMxk2NdGSkcAzRvM7BiysnWdnV5ZKdfRHZGIkUUN605fLQmjTzv5Fv5eH2isN7M0v hQq7bHcfdDPFf2fu8qG3YILri+l9s1ub6O3w+2c1Iy23r0hw2ewwKgAFVgLk6FfjtaRH emn1ltoDOmk0PfL1n9KoeJ44HOikqFLRDHJayP/7t8FYzbD0FR6BecQqmxcUc/YHI+sl apXA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si4714557plf.58.2021.04.22.23.26.03; Thu, 22 Apr 2021 23:26:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236955AbhDWGZz (ORCPT + 99 others); Fri, 23 Apr 2021 02:25:55 -0400 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:28514 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240645AbhDWGZt (ORCPT ); Fri, 23 Apr 2021 02:25:49 -0400 Received: from localhost.localdomain ([86.243.172.93]) by mwinf5d49 with ME id w6RC2400421Fzsu036RCl9; Fri, 23 Apr 2021 08:25:12 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 23 Apr 2021 08:25:12 +0200 X-ME-IP: 86.243.172.93 From: Christophe JAILLET To: mturquette@baylibre.com, sboyd@kernel.org, gregory.clement@bootlin.com, thomas.petazzoni@free-electrons.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/4] clk: mvebu: Fix a another memory leak in an error handling path Date: Fri, 23 Apr 2021 08:25:10 +0200 Message-Id: <5f1ba3fb1950a2743ec8c4baa4b4925f134c0f28.1619157996.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we exit the for_each_of_cpu_node loop early, the reference on the current node must be decremented, otherwise there is a leak. Fixes: ab8ba01b3fe5 ("clk: mvebu: add armada-370-xp CPU specific clocks") Signed-off-by: Christophe JAILLET --- drivers/clk/mvebu/clk-cpu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mvebu/clk-cpu.c b/drivers/clk/mvebu/clk-cpu.c index a11d7273fcc7..9a5c2aec6ec2 100644 --- a/drivers/clk/mvebu/clk-cpu.c +++ b/drivers/clk/mvebu/clk-cpu.c @@ -199,11 +199,14 @@ static void __init of_cpu_clk_setup(struct device_node *node) int cpu, err; err = of_property_read_u32(dn, "reg", &cpu); - if (WARN_ON(err)) + if (WARN_ON(err)) { + of_node_put(dn); goto bail_out; + } clk_name = kasprintf(GFP_KERNEL, "cpu%d", cpu); if (WARN_ON(!clk_name)) { + of_node_put(dn); goto bail_out; } @@ -222,8 +225,10 @@ static void __init of_cpu_clk_setup(struct device_node *node) init.num_parents = 1; clk = clk_register(NULL, &cpuclk[cpu].hw); - if (WARN_ON(IS_ERR(clk))) + if (WARN_ON(IS_ERR(clk))) { + of_node_put(dn); goto bail_out; + } clks[cpu] = clk; } clk_data.clk_num = MAX_CPU; -- 2.27.0