Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4254217rwb; Sun, 7 Aug 2022 19:27:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR5pL/Px0U+/T5OGM/TKHUZZYX6xMzgaFykmodDrxEduneKvNydribuzGOsZMmPtqpWuh5nt X-Received: by 2002:a17:906:668b:b0:730:a5b7:8985 with SMTP id z11-20020a170906668b00b00730a5b78985mr11705415ejo.548.1659925631566; Sun, 07 Aug 2022 19:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659925631; cv=none; d=google.com; s=arc-20160816; b=ZE1Jd4krf3cl98VRhk/4L8ANu0+Zj0WB4x/FXgwP8VFg5+IGXsJ0JTDelS2GZyKtPe +GmXq+y61vFqYWVm+S5zS+W5lA+mCGr3ZHy4idjvgD7vhX3DkpecptX7OoCyFcNUdRZe mKF0fINS35Wn7PFUje888sxHeKWx35O4638WJjU6PliLz1kVc/PjtKwSegEytvE4bH+E sE1E2cJv0cC7FJuK5ISLfXlWiX5Zv5ANVIKaHUv40OyUIjOiO3geS2hnB5H7bPqXE3Ou 3YALwWn0yo9uzhKze6AyScSg5ENjjGtUWieLtCDxEHzOH/9p2SenAiSUy/y7ttcDDmh5 xdfg== 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=zkYGwkTHEZBrdZTaNeswfPU4mUaPGHKAKWFFcqBlRaE=; b=Kn7FpWAvH9PiGUMOPAOv1wRvOyjUMdOYxkMiqHv1xmfI/EVSz1moEswHnEr3+cwfMO oHLq0XfpuFFFAL3+ZyIjIXpDOJ4YgsYLnB9J1RZmRWXsRWLK5vTKnIWtl73HgF6z6pzx RqXOpftTlvFE/EHp+R/KWGSmsWgvRWMhcPTHLf3aZAVm8m1QvfKU3o0TqV3debX0cFvu gqHxL9BgKEFrQU8sAEohbR6qsahVIOZ7PwBKXQTlDVkJFNT1eF/khtfw6635vVaIRxdZ aridtnF+foZS8Qds0VucX2iG9/i+dzWvw/m3C6q2wcRrhN5rGOZS3bmWVF3pMQlSxnoO Slug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kT4LUcV1; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz9-20020a1709077d8900b00709af14e386si7828348ejc.205.2022.08.07.19.26.46; Sun, 07 Aug 2022 19:27:11 -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=@kernel.org header.s=k20201202 header.b=kT4LUcV1; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242498AbiHHBhM (ORCPT + 99 others); Sun, 7 Aug 2022 21:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242273AbiHHBfq (ORCPT ); Sun, 7 Aug 2022 21:35:46 -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 EC337CE1C; Sun, 7 Aug 2022 18:33:19 -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 A0158B80DDF; Mon, 8 Aug 2022 01:33:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CD92C4347C; Mon, 8 Aug 2022 01:33:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659922397; bh=uoQNnByv+1FbqqjWQwrzqaf0ot43bfZtPaAvo624/cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kT4LUcV1z8sqcefZByoy/jUUthOXGGjBkaSKdO25g8nvZCilNTWt4QSk8+CNymbji rz87au05i8++Lgld/UHPmY9h2vlNX2PBKCJ3AjmKb+mwT26RxuxUsL09pP7UW48F7l 0DT3Ezf6O/NtidoBeID1ZFH8DlWdSNhhtMuuadiQiXgYrhY9G2+Ddyqwq1tXjnCbMA pLqx+pxx2xZOhqHUsPOTFuIL7IwJs6yjRs0k4eAgT/SwclvpcybNhiXGLW+dlRNyHR tv8MEMDeJwxKZn+aYpvMUzXpPHldYt99KrjNThcjJjYFQSCeFN6eM6vXA0dMI9KpZp JuJc31Ulii2GA== 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-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH AUTOSEL 5.19 46/58] ARM: shmobile: rcar-gen2: Increase refcount for new reference Date: Sun, 7 Aug 2022 21:31:04 -0400 Message-Id: <20220808013118.313965-46-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220808013118.313965-1-sashal@kernel.org> References: <20220808013118.313965-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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 abea41f7782e..117e7b07995b 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