From nobody Wed Sep 10 01:53:18 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AC29221546; Mon, 8 Sep 2025 15:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757345067; cv=none; b=ExmreF4ztPwWhJ53BVUAKSQg5c2qoTpPL+R6NmLLatosst6WOXXYNX23eXkgnNidJb5LJyaih2JvgawrL6etJrUlUo/EefvfeGXvXfAOzKIg6EYCUgdBBWP4zKx72qKdxTY223IH0eHLWrv14jcy0n3JLXUqRC1msmf8SbEpPj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757345067; c=relaxed/simple; bh=F3qaWkwKt9cdMvSRM6WVc3wT/RqouyGxmJ6H6L5Udxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a2JUbd/BOGcFDLxe006ndDQMmclq/GtGBSVAU4Kb7aOqtBIZKDxQa5VjuqilVhG41XxvcO9R60NEz3z/EjF2RbGyh3AvxWO1KhkFseM5dscwrofZpUfu23u11IUNbOtdBvJYxB3RwA//SULFy3QSmAt2qJduNd+IY3L1CgRLbDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XCfKPzi7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XCfKPzi7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 030DEC4CEF1; Mon, 8 Sep 2025 15:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757345067; bh=F3qaWkwKt9cdMvSRM6WVc3wT/RqouyGxmJ6H6L5Udxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XCfKPzi79lXScX38n+sryt0AldiXsmLEHRz8sLfamvCmyJKiCq8NKkNBYAUYsLh+f asYFxzWRWpeWN4MX0HFNNq7yvs2930v+z1bOZLjMu5aNDnMTQzUrbZGgAs55qT/zzr gLMAjBbDi0qdCM8TUlfbzUIPItUR6/laNMsIcrzxpPeTbJpzAmS7y90QHsUebxB7o0 TjFq0Y5XprmW7GjoUK1rpECk/F058Ph2eRZnJ5by+Y3/2lSFEsNxNuoROtsV3YiR9O MZIvMoz5LcbcoxZyXkqhzLSguXd63S6KcRymbMwjj9Qao7M0XF7F2QoMC/9/B24xlN rmGFSga6R2gPA== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1uvdjF-0000000080a-1gbp; Mon, 08 Sep 2025 17:24:25 +0200 From: Johan Hovold To: "Rafael J. Wysocki" , Daniel Lezcano Cc: AngeloGioacchino Del Regno , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 1/2] cpuidle: qcom-spm: fix device and OF node leaks at probe Date: Mon, 8 Sep 2025 17:22:12 +0200 Message-ID: <20250908152213.30621-2-johan@kernel.org> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250908152213.30621-1-johan@kernel.org> References: <20250908152213.30621-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make sure to drop the reference to the saw device taken by of_find_device_by_node() after retrieving its driver data during probe(). Also drop the reference to the CPU node sooner to avoid leaking it in case there is no saw node or device. Fixes: 60f3692b5f0b ("cpuidle: qcom_spm: Detach state machine from main SPM= handling") Cc: AngeloGioacchino Del Regno Signed-off-by: Johan Hovold Reviewed-by: Konrad Dybcio --- drivers/cpuidle/cpuidle-qcom-spm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/cpuidle-qcom-spm.c b/drivers/cpuidle/cpuidle-q= com-spm.c index 5f386761b156..f60a4cf53642 100644 --- a/drivers/cpuidle/cpuidle-qcom-spm.c +++ b/drivers/cpuidle/cpuidle-qcom-spm.c @@ -96,20 +96,23 @@ static int spm_cpuidle_register(struct device *cpuidle_= dev, int cpu) return -ENODEV; =20 saw_node =3D of_parse_phandle(cpu_node, "qcom,saw", 0); + of_node_put(cpu_node); if (!saw_node) return -ENODEV; =20 pdev =3D of_find_device_by_node(saw_node); of_node_put(saw_node); - of_node_put(cpu_node); if (!pdev) return -ENODEV; =20 data =3D devm_kzalloc(cpuidle_dev, sizeof(*data), GFP_KERNEL); - if (!data) + if (!data) { + put_device(&pdev->dev); return -ENOMEM; + } =20 data->spm =3D dev_get_drvdata(&pdev->dev); + put_device(&pdev->dev); if (!data->spm) return -EINVAL; =20 --=20 2.49.1 From nobody Wed Sep 10 01:53:18 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ABCF25634; Mon, 8 Sep 2025 15:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757345067; cv=none; b=dJkTKY+bChF0ZEFbXqe5pmgVLkEw3gxjmtbwc4KQpzaGMk+2ERQh4pJLsaRZmcbTDsTWw4pr+i5MHx9G4DB9Kq1J6zkw4988PKAFp2h5C8zsIH+oYsoMUtrHMYsUf/NecZyHFMPCe3HMo9yTaJiiaT5MyuOLfusRGz+G3Ale4ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757345067; c=relaxed/simple; bh=XGZbwTONSmzAq2Qk/5cr9aqST0TZSvlYH6pzLmFcKTQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CcjvYRXLc8/LDKyFeGrMN2c27qnKjknG8w4vaHrgUKrnl8ECFuz643c9lBq+M02ceoA1P7LaRsoERu20mFE6o9xZq4064vIIMn2u0gKbKs39b8tOOKTzD0lZAOHNgQbYq/Ili2ETt/3I54MkpzX/N+VFVKKFdmmHRhOGHHPNUuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aJExGRa1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aJExGRa1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 066D2C4CEF7; Mon, 8 Sep 2025 15:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757345067; bh=XGZbwTONSmzAq2Qk/5cr9aqST0TZSvlYH6pzLmFcKTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aJExGRa1uSAxPPR69okuzb67kOPyztd18IYtOdhu0fYc5ebUNgG8Ggdamq70Rnd1k om35DBKqj7KGW5lC8KvGxRTavvHqMky4CgbPXfCB9IDAjwTWqZt+Ors2aeM1hmeVCG FH++ZOBq8YTdp4Ca0aXnqGuyikQQaP0cfxelz4DR2VuNG5PRW+Jt/NvAoHz/JaCCvK z0dKmFu5r22sQStLq2nNsSjGq4mmA82vTfOZYxPrutUMisoKfPMPEIzet64LkORUD2 2VcIrdGiZOM/6CQm3NamnfMsxGlolC4YoSdaNRjzYfxPTYs3uk9U0ivoQGtj9hHPM4 xl0buuyk04Xuw== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1uvdjF-0000000080c-22Mh; Mon, 08 Sep 2025 17:24:25 +0200 From: Johan Hovold To: "Rafael J. Wysocki" , Daniel Lezcano Cc: AngeloGioacchino Del Regno , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/2] cpuidle: qcom-spm: drop unnecessary initialisations Date: Mon, 8 Sep 2025 17:22:13 +0200 Message-ID: <20250908152213.30621-3-johan@kernel.org> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250908152213.30621-1-johan@kernel.org> References: <20250908152213.30621-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drop the unnecessary initialisations of the platform device and driver data pointers which are assigned on first use when registering the cpuidle device during probe. Signed-off-by: Johan Hovold Reviewed-by: Konrad Dybcio --- drivers/cpuidle/cpuidle-qcom-spm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/cpuidle-qcom-spm.c b/drivers/cpuidle/cpuidle-q= com-spm.c index f60a4cf53642..7ab6f68b96a8 100644 --- a/drivers/cpuidle/cpuidle-qcom-spm.c +++ b/drivers/cpuidle/cpuidle-qcom-spm.c @@ -86,9 +86,9 @@ static const struct of_device_id qcom_idle_state_match[] = =3D { =20 static int spm_cpuidle_register(struct device *cpuidle_dev, int cpu) { - struct platform_device *pdev =3D NULL; + struct platform_device *pdev; struct device_node *cpu_node, *saw_node; - struct cpuidle_qcom_spm_data *data =3D NULL; + struct cpuidle_qcom_spm_data *data; int ret; =20 cpu_node =3D of_cpu_device_node_get(cpu); --=20 2.49.1