From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 186F3C19F2A for ; Mon, 8 Aug 2022 01:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243498AbiHHByl (ORCPT ); Sun, 7 Aug 2022 21:54:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243627AbiHHBv2 (ORCPT ); Sun, 7 Aug 2022 21:51:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5CEF193F3; Sun, 7 Aug 2022 18:38:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2082560E06; Mon, 8 Aug 2022 01:38:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90D80C433C1; Mon, 8 Aug 2022 01:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659922701; bh=hwBSpc7erig/674qMUa5THYn7tKXm6QBe24djanajcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CwuUzKh11NqF3YccmbX6LFxs7a5CmyuDxk2VGm9KPnZT53zN8JAXe69H2YUIt3XQh hJO44JCsIbUk31KIctGN5Ar7dXG+xMRkPDZ1Byu/Gz70jaZ5JiPLsLOVV7Ol7KTUOj 0GffDxkxU024zqJkDHVK/X/RbTV6nShcypEuswF9RCeSUn5+r7HXqiCiIINlThbTJO lBtwIYc1Kp6RiKXKbAJ00ppqW4NuDKDeapo5mq3iEpbRn5WxLk96wn/jAyI7tFC+V1 RjuDq//FLvVqjS/DvgTCrPHOw+M0RF+8rQZvOUvCqJjWV6UEzpYGnM42K6Z9PcFQQ2 lfZYHq31jYaUg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Liang He , Geert Uytterhoeven , Sasha Levin , magnus.damm@gmail.com, linux@armlinux.org.uk, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 25/29] ARM: shmobile: rcar-gen2: Increase refcount for new reference Date: Sun, 7 Aug 2022 21:37:35 -0400 Message-Id: <20220808013741.316026-25-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220808013741.316026-1-sashal@kernel.org> References: <20220808013741.316026-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: Liang He [ Upstream commit 75a185fb92e58ccd3670258d8d3b826bd2fa6d29 ] In rcar_gen2_regulator_quirk(), for_each_matching_node_and_match() will automatically increase and decrease the refcount. However, we should call of_node_get() for the new reference created in 'quirk->np'. Besides, we also should call of_node_put() before the 'quirk' being freed. Signed-off-by: Liang He Link: https://lore.kernel.org/r/20220701121804.234223-1-windhl@126.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin --- arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c index 09ef73b99dd8..ba44cec5e59a 100644 --- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c +++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c @@ -125,6 +125,7 @@ static int regulator_quirk_notify(struct notifier_block *nb, list_for_each_entry_safe(pos, tmp, &quirk_list, list) { list_del(&pos->list); + of_node_put(pos->np); kfree(pos); } @@ -174,11 +175,12 @@ static int __init rcar_gen2_regulator_quirk(void) memcpy(&quirk->i2c_msg, id->data, sizeof(quirk->i2c_msg)); quirk->id = id; - quirk->np = np; + quirk->np = of_node_get(np); quirk->i2c_msg.addr = addr; ret = of_irq_parse_one(np, 0, argsa); if (ret) { /* Skip invalid entry and continue */ + of_node_put(np); kfree(quirk); continue; } @@ -225,6 +227,7 @@ static int __init rcar_gen2_regulator_quirk(void) err_mem: list_for_each_entry_safe(pos, tmp, &quirk_list, list) { list_del(&pos->list); + of_node_put(pos->np); kfree(pos); } -- 2.35.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CEF56C19F2A for ; Mon, 8 Aug 2022 02:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1GGKF0o9ExRkD+ceMfkO898984DzsyskdOSrCeu0p4Y=; b=gM3lLtQSbEmH+j n+3JGKYDGYjcJussJkQzGT4Iy0Cw1Sa1kg62I7To0eKQKF44igaA5q9kybo7Fii0gDw+5eFGUkU9P FDmrgcBJd7hSbmxEiAi8ngPkUOmH1klLY7W0rG4S4jxxEL5kQrTjOuQusCPxXedeWcCcJ1iq3yHDT wxJhi586rAyjRN6MQhjSBWhbudxCeZAg9uGdKO8ouq+yfHhV0mRI0R7uQ88bz7K/Rwt33dUOHEt9A iXmL08flxaLY4PregeRpl+Pg4qbLN3tlPh6UawMElZvk8wV9Ooz8z1aGIcJJg+F1/+MrxkqibBppK FPO5O87xTISEKvL1TYww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKsZG-0082ba-53; Mon, 08 Aug 2022 02:32:34 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKrio-007eps-Lq for linux-arm-kernel@lists.infradead.org; Mon, 08 Aug 2022 01:38:25 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 20FBE60DF5; Mon, 8 Aug 2022 01:38:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90D80C433C1; Mon, 8 Aug 2022 01:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659922701; bh=hwBSpc7erig/674qMUa5THYn7tKXm6QBe24djanajcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CwuUzKh11NqF3YccmbX6LFxs7a5CmyuDxk2VGm9KPnZT53zN8JAXe69H2YUIt3XQh hJO44JCsIbUk31KIctGN5Ar7dXG+xMRkPDZ1Byu/Gz70jaZ5JiPLsLOVV7Ol7KTUOj 0GffDxkxU024zqJkDHVK/X/RbTV6nShcypEuswF9RCeSUn5+r7HXqiCiIINlThbTJO lBtwIYc1Kp6RiKXKbAJ00ppqW4NuDKDeapo5mq3iEpbRn5WxLk96wn/jAyI7tFC+V1 RjuDq//FLvVqjS/DvgTCrPHOw+M0RF+8rQZvOUvCqJjWV6UEzpYGnM42K6Z9PcFQQ2 lfZYHq31jYaUg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Liang He , Geert Uytterhoeven , Sasha Levin , magnus.damm@gmail.com, linux@armlinux.org.uk, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 25/29] ARM: shmobile: rcar-gen2: Increase refcount for new reference Date: Sun, 7 Aug 2022 21:37:35 -0400 Message-Id: <20220808013741.316026-25-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220808013741.316026-1-sashal@kernel.org> References: <20220808013741.316026-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220807_183823_952952_F9DA3F90 X-CRM114-Status: GOOD ( 14.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Liang He [ Upstream commit 75a185fb92e58ccd3670258d8d3b826bd2fa6d29 ] In rcar_gen2_regulator_quirk(), for_each_matching_node_and_match() will automatically increase and decrease the refcount. However, we should call of_node_get() for the new reference created in 'quirk->np'. Besides, we also should call of_node_put() before the 'quirk' being freed. Signed-off-by: Liang He Link: https://lore.kernel.org/r/20220701121804.234223-1-windhl@126.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin --- arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c index 09ef73b99dd8..ba44cec5e59a 100644 --- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c +++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c @@ -125,6 +125,7 @@ static int regulator_quirk_notify(struct notifier_block *nb, list_for_each_entry_safe(pos, tmp, &quirk_list, list) { list_del(&pos->list); + of_node_put(pos->np); kfree(pos); } @@ -174,11 +175,12 @@ static int __init rcar_gen2_regulator_quirk(void) memcpy(&quirk->i2c_msg, id->data, sizeof(quirk->i2c_msg)); quirk->id = id; - quirk->np = np; + quirk->np = of_node_get(np); quirk->i2c_msg.addr = addr; ret = of_irq_parse_one(np, 0, argsa); if (ret) { /* Skip invalid entry and continue */ + of_node_put(np); kfree(quirk); continue; } @@ -225,6 +227,7 @@ static int __init rcar_gen2_regulator_quirk(void) err_mem: list_for_each_entry_safe(pos, tmp, &quirk_list, list) { list_del(&pos->list); + of_node_put(pos->np); kfree(pos); } -- 2.35.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel