Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3202086pxk; Mon, 21 Sep 2020 07:46:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfnUI3Erb5RF6AcdNCmKlqZ8nUvnM/CQKv54JRrjsVHzG3xcQ8ngeeaMxZf8qswHU2772t X-Received: by 2002:a17:906:b146:: with SMTP id bt6mr49370655ejb.287.1600699561608; Mon, 21 Sep 2020 07:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600699561; cv=none; d=google.com; s=arc-20160816; b=L0xYoVB4JpOjjAABlg4rU4kqNKR3qPCPnr3ghCAI0cE+yHL4gfCNuN9WDzLS0Yp4EF l0j9NIcyj2Mv8KZwCTjI7q9F7SMrEA8bAgFUksLoV2q95innDLNAUTIsodjQX7xP0ygh EMZIZNxEdcxShm9cNq7BvO0qWnoUNgF6fCBeUVbK7rw8uw40onQ+ejXCHVxwBh+VxG7i 8L+d5bzviSd1YpUZhPkn4OBK55BOaMP2YDDIxmFv5DTLOXeNVBI9MU1TfEuwRZ2b6+Z6 dJEDKuy9v4CywWxjUNnFpnvI1UCO0WQFiOlOf5aEXo/fwc/Tadi0MYD2zXktwrV+3N4D OIVw== 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 :dkim-signature; bh=lY8MouDjmMbB7uVWM6EHAy39XzZK0FOj3ckJO4jhY70=; b=abwXB1CX3XRv5czjHf9qszR4QBcskM5RCP66zyG3zV1+uX7PrPDtNnBASe36E4nCBQ 8oy5I/G3xg4F3DyZ0gUgB+NGuj7S61XQK0oD/7PLVJS/i4HSVoKMPOBWZ88ekONOWsBI 29/Nhln2DLU529xvjVyo/SBMkXPjWDB01elAkro2Ca5CLQks2O7n6x9U/BJdEVdLkwfW aPn5JaI37OZgQ7lmLAgndHrHS/6DlPKUyVi18MNdw0NUJbKgNKXRMQ/2BL63dPGWY94V g7k89ZjR3sgf7WfdRU8fS/y0IP3Uf2IQSlh+j12Hol3UOseJIQLVXBfOCOxOyYAOQlBr ByLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U8O9W0WT; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si5892248ejw.413.2020.09.21.07.45.38; Mon, 21 Sep 2020 07:46:01 -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=@kernel.org header.s=default header.b=U8O9W0WT; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbgIUOki (ORCPT + 99 others); Mon, 21 Sep 2020 10:40:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:49202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727499AbgIUOkg (ORCPT ); Mon, 21 Sep 2020 10:40:36 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DBABB23718; Mon, 21 Sep 2020 14:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600699235; bh=hlCTEfeCQncgpBOMjD101cTzGYTMWM+Cj52a8KqvpF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U8O9W0WTbXKk5tbDZC+Rm7geFkXvURdAtwNzJ02go78CprNUhXBicFKk7Fp7ZO5An lkRM8M5RvS4j4KRvoX+m1O5y0nMlCX1O7Jcu7m7mUpUDYmT/hFsqN42W6MmLA9LpBU 8u/wqTTpLup1E8wY6LufG4bw0ga93+RGVhTqp6T0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sumera Priyadarsini , Linus Walleij , Stephen Boyd , Sasha Levin , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 06/20] clk: versatile: Add of_node_put() before return statement Date: Mon, 21 Sep 2020 10:40:13 -0400 Message-Id: <20200921144027.2135390-6-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200921144027.2135390-1-sashal@kernel.org> References: <20200921144027.2135390-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sumera Priyadarsini [ Upstream commit da9c43dc0e2ec5c42a3d414e389feb30467000e2 ] 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 Link: https://lore.kernel.org/r/20200829175704.GA10998@Kaladin Reviewed-by: Linus Walleij Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- 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 ca798249544d0..85c395df9c008 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.25.1