Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1865341rwb; Fri, 19 Aug 2022 10:40:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR6xEAXC6biYrN//3jBoenVEOBLfHYTiFof4n2KYjdaHvDb76l3qoyrlPvM1Wap7hx0VSgv7 X-Received: by 2002:a17:902:8605:b0:16b:e755:3c6e with SMTP id f5-20020a170902860500b0016be7553c6emr8335223plo.42.1660930825199; Fri, 19 Aug 2022 10:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930825; cv=none; d=google.com; s=arc-20160816; b=yWNhQj6gArq8X700TWGN/H2f2rnFS5PbIE9B0LZyxlmyrC7ABREfW6KQ0HaPvEGVRM 9wBbjYVaS/WaGNfTtEbUHvDVPZ2BiISzvd3IsLhTadFQBnL8y6wICnKcuOTsQP2s0PkL F1XYy31IS8uMu7fsDv403bdBDogMpNE4kWrlX/dgjSb3en+anbyvSRDRAZvLd4tmNIaj D9suvodrWFs4tP/UNyco15MpOlxGaXEC1B7GHxYmgdjXkqNgsrBL8RLPA6DXg4DRZvss Ul4l3+GId+OVWgttOTvCtSCq+bLxVg6YABxqrtXkdVQPWB2tNjH3SOUdnuDbULbfq+LE 2PBA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9Rfv2RlxWaQ33rlSz3bWk+3VJ153MuIjmzOcxdbtJOY=; b=yEHUdCYVis+jlWKaesbU3cP48IP1OQlLdrsN2LQDVzbOXjGl6jYLzV4lM8l92Fvwmg EavRAenGKXG4BYwxtrObIXKbWJZZERzsg9fem+jyOfZQsEmq6myMxwq6ArGqLb1t1kDB yuIkz77W42iABATPtuok3RlhucxZS0v7gmEHQyCghPcpYAIRzDm1aGJ6PvwUK8N2KvIj suuFVjtR9WuPicyOu4iyFP9EX1dC6gFhJXTcdjUqGMYVI8kXj5Ff/xBinvlTd8LGkIYX EuDmaXZxw26cFtft27MJQMV+QvTtupvhrbJPQf7HO1KLSU7RQOGTV076XhVRPpdlqLif LBlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=11OIJrzO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l184-20020a6391c1000000b004161e62a42fsi4407461pge.830.2022.08.19.10.40.14; Fri, 19 Aug 2022 10:40:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=11OIJrzO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350008AbiHSP5j (ORCPT + 99 others); Fri, 19 Aug 2022 11:57:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350861AbiHSPzy (ORCPT ); Fri, 19 Aug 2022 11:55:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E19910522D; Fri, 19 Aug 2022 08:50:38 -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 ams.source.kernel.org (Postfix) with ESMTPS id 96015B82812; Fri, 19 Aug 2022 15:50:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDCF3C433C1; Fri, 19 Aug 2022 15:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924234; bh=hwBSpc7erig/674qMUa5THYn7tKXm6QBe24djanajcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=11OIJrzOBXlEF/hw++wClartAFy+ho27mll2Ky3P9oc3kMhMFMpyiWvc52pTtRq7f 6qLsyE8iagJs2eGeNXEikr1LzSM7Ydl9sMl6z3V+8+2qhG3p0bK5eqhHItpPsGdr/x Rjn+fw8ugnhwZGrwUVJBR26etINkDYo3cM8Va7qQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Geert Uytterhoeven , Sasha Levin Subject: [PATCH 5.10 101/545] ARM: shmobile: rcar-gen2: Increase refcount for new reference Date: Fri, 19 Aug 2022 17:37:51 +0200 Message-Id: <20220819153833.795054640@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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