From nobody Mon Jun 8 06:39:47 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08B30330B14 for ; Fri, 5 Jun 2026 20:19:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780690751; cv=none; b=IUrA4uvLuNahAoELi5xXZ8K9aL9nFGS/kqUqz2sUvUZKbfN1q/kz+rOqSF4az/CIlf1kTrsw/jSUAZ5M8du3nZ6+a5KPXdtaA88S5u8JUytWmlUKLbZl3bieWe3C2jUp71Z2xa0sNmgvmJsykAPYjyBxw3/sFRk8MY/tIf8yqis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780690751; c=relaxed/simple; bh=i/hR1lgYvHPPw5OPf+wLO0gns47TKhXDAvO92AjK7uI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QuNmqdl9maSG4TZdILRYN1CVHFIkVl1rW9o2gJRrRVMN2CqcqCmphw3/dfCOvRaOWDfQGI3sSe0zH6xk1EkeVJkPO6jxUXVPrxanhQoTwZzHKCsFRZrPIP2vTUnT/o6k8lDFrdbBGEnWtW4slTJ1PM3EQmbvdePmIVilN4YYK4A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=TkXvAbFe; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TkXvAbFe" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490c0c92cffso13864545e9.2 for ; Fri, 05 Jun 2026 13:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780690748; x=1781295548; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=l0yxG0zXdk7r1+vfGjZGqqrFGTovMPDmklAlD/sL2QA=; b=TkXvAbFeHWMdhfNM4Z+6MVi+bcHQfYTeoFNgsekLaEWSBp4UN3tq3u6mp1CsSz/xNq nII5/FfIbO7lOr3kdq0dVVvic6DqrI9gnUphap4AEjZTxDpqqA63K5wClsBP4SQHl20V aEmOvfv2c6hpqTud5m7UpUgeduu+y2uMCMYPl/ZXOMzLGSPnEZ4zwH4Ca82V7+cT0Kts psvZ5XXmX9OZ9IwfzmAi8YOpi0pserHH3kBEqxbL2FP+XMg1rwr1p9SR7W0wUBSk0f0O gU5laXzD7+44+bH6aBC4ZrNtG3ujI1XHuwPofzxzkW0mJpa2JAXHjdmqMweVQTQTSIxe pcAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780690748; x=1781295548; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=l0yxG0zXdk7r1+vfGjZGqqrFGTovMPDmklAlD/sL2QA=; b=WxLWquzN/ddfTnIyml/7AAsBjpUfIfh4CxZYCEpwvsiV4g4KpdAkYF/z+90A9cuCdi mINXk6dFJPJ18NZTPurVX1C79Z+9p/Jbn7MTbsaowzzso2k+0uvkTeDjUOoN8If2GIcU NTmPAW7Oe4CD5RYEL9SnlvgblkKJd+aX34SkzMC9piZtB3Sndas/glJeMRorAcW/9wm1 T3vGWxH26Lx3dQSj+Wua3lF/vA0dBFOX9WNH7yEV53MmC7Qn/fIP4Scnzuixgia3tVSR Ir+7TXcUZEbQPrjmbiA2bLFzcBAEFtl646ikyG1bafIBl3onbhhT3nvyeJ6fhnHP0Dht uRpw== X-Forwarded-Encrypted: i=1; AFNElJ9fmmUki0XW2AnlmY6+Eq3RuQrkOb0YMTBw4MyIqzLITz9+H6Jtq1poAR92T+mQE1487W9F8RaBaExTKrE=@vger.kernel.org X-Gm-Message-State: AOJu0YxGQXTOXpi6zyw12ifR9PSpKCIV/CfUiuw4sbGu1NOuGSljTunV 7XlfJn81fM/q/TgeOzn5vzKt6q+N5nMjKTEjqSg+DzQFC9OcptnCX7j7G/1/jCxwXA0= X-Gm-Gg: Acq92OGvs0W+aHw4HzpVvz/3+Cu26msvWFpB/raj9q/Or1ZN4OQEoalowzGDLiwcrNz NSRnH+CGOHfUDigrEdf41KSnDJTnkaETRWymG4+kSPRu+08/NG5I1BB2AmHbyswJwR5geb5SuFp f1ACwp2+TV4deyWWRkHTIsdm6UQqc4R8zWamVHets3xUIiH2yl4LD4RpS39lP6MqksywSy/XGh0 OLLobZWHlkqwoOcP51PBhw813bCCwtDOHr2tclQTNY1hTeJ3Y1W73WsDdBmSASXKdFe/399L2In vemmXL6WhPwyLyNaXRyTE/cWXhvl+1JsIguWfmPuEcYIfymQSz2P+smA5Enw2V/rQhxdbaTiYHL D/d/FEGfPPk8+Ll2FsUFB9XddkYCP9/BWAKKxaP/0fVieqsN6O+Qj9odzaZFasGOBOMhLmeMcSH c49RSyF6NF5T9ey08MeHoOdct/MFyk9oc8C1lrpHHTWdNGi05Vy8mj8FK7r+qX/V3bG01OuGmdz SikF7GHgBVWOtDg9vlRaRkgN4g= X-Received: by 2002:a05:600c:8b68:b0:490:bad7:3634 with SMTP id 5b1f17b1804b1-490c25e1104mr89266485e9.19.1780690748518; Fri, 05 Jun 2026 13:19:08 -0700 (PDT) Received: from [127.0.1.1] ([94.4.195.193]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc413541sm190533895e9.14.2026.06.05.13.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 13:19:08 -0700 (PDT) From: Alexey Klimov Date: Fri, 05 Jun 2026 21:18:50 +0100 Subject: [PATCH 1/3] soc: samsung: exynos-pmu: use target cpu ID in hotplug callbacks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-1-0cd05c81a82d@linaro.org> References: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-0-0cd05c81a82d@linaro.org> In-Reply-To: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-0-0cd05c81a82d@linaro.org> To: Krzysztof Kozlowski , Alim Akhtar , Peter Griffin Cc: Sam Protsenko , linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Sashiko X-Mailer: b4 0.14.3 The CPU hotplug state callbacks __gs101_cpu_pmu_online() and __gs101_cpu_pmu_offline() currently partially use smp_processor_id() to determine the target register offset for the CPU inform hints. This may be fine for cpuidle flow but broken for cpu hotplug where the target cpu is passed as an argument and could be different from cpu where that is executing (e.g. CPU 0 offlining CPU 1), meaning that smp_processor_id() returns the id of local CPU but hotplug flow deals with another CPU core undergoing the transition. This causes the pmu driver to write power down and power on configuration hints to the wrong hardware registers, messing up the power state of active cores and failing to configure the target core. Fix this by removing the cpuhint variable entirely and utilizing the target 'cpu' argument passed to the callbacks by the hotplug core infrastructure. Reported-by: Sashiko Closes: https://sashiko.dev/#/patchset/20260513-exynos850-cpuhotplug-v4-0-5= 4fec5f65362@linaro.org?part=3D3 Fixes: 598995027b91 ("soc: samsung: exynos-pmu: enable CPU hotplug support = for gs101") Cc: stable@vger.kernel.org Signed-off-by: Alexey Klimov --- drivers/soc/samsung/exynos-pmu.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-= pmu.c index d58376c38179..6e635872247a 100644 --- a/drivers/soc/samsung/exynos-pmu.c +++ b/drivers/soc/samsung/exynos-pmu.c @@ -235,11 +235,10 @@ EXPORT_SYMBOL_GPL(exynos_get_pmu_regmap_by_phandle); static int __gs101_cpu_pmu_online(unsigned int cpu) __must_hold(&pmu_context->cpupm_lock) { - unsigned int cpuhint =3D smp_processor_id(); u32 reg, mask; =20 /* clear cpu inform hint */ - regmap_write(pmu_context->pmureg, GS101_CPU_INFORM(cpuhint), + regmap_write(pmu_context->pmureg, GS101_CPU_INFORM(cpu), CPU_INFORM_CLEAR); =20 mask =3D BIT(cpu); @@ -296,12 +295,10 @@ static int gs101_cpuhp_pmu_online(unsigned int cpu) static int __gs101_cpu_pmu_offline(unsigned int cpu) __must_hold(&pmu_context->cpupm_lock) { - unsigned int cpuhint =3D smp_processor_id(); u32 reg, mask; =20 /* set cpu inform hint */ - regmap_write(pmu_context->pmureg, GS101_CPU_INFORM(cpuhint), - CPU_INFORM_C2); + regmap_write(pmu_context->pmureg, GS101_CPU_INFORM(cpu), CPU_INFORM_C2); =20 mask =3D BIT(cpu); regmap_update_bits(pmu_context->pmuintrgen, GS101_GRP2_INTR_BID_ENABLE, --=20 2.51.0 From nobody Mon Jun 8 06:39:47 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C57B535E1A8 for ; Fri, 5 Jun 2026 20:19:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780690752; cv=none; b=SqG3g007bfuEYbQdcZaqMX4N+OKE1pgqusgwU1PO4mSy3I04CJ3LlClqaB/Tb5Logy0XrjMAjtz6g9xVamQfgmKplDxnmX3TB1QLXSExJQMWrkjDcCzlT+aKhlZJRGNz0jiWdD/Vt/U4BEyry0x2v0PLljPUyIri/n5tl91h8gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780690752; c=relaxed/simple; bh=3+EoLxOX4bdQUndqS5N43k5aUc6u3qE6NwCEB7j7zJc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hQMoA6dCQNwy26k5zZe/krYSENgJQbEwU9OthO/iD/1wSq8yqLAg7ZPUtiq+rOepH1RqY0DW3Jt2OuzE1tv6TuS4SF3CD576uE7Gd2NugR7aVc/+BA1H6Bp9jjvKs+rcb5LAJ8ML7cT7krozXG6QjBV1kU1/YNM4PBPJvNxLXbk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=D24oiVVR; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="D24oiVVR" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-490b613a17bso22851045e9.3 for ; Fri, 05 Jun 2026 13:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780690749; x=1781295549; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fEynX1/cef0pndZEPm8gcDuGDO9NpbMBOZFQHs0cVw4=; b=D24oiVVRxDGLz2uS5ycdAbGhK/v8jpNwPQ3bq2wCWgd2JLyFHQzWyorXu+n0CkuM2v 0tWgRp6F8z2wKTZMnjCVfu5aASmhteYDUGFUlEpQ0FMkqWzoEbId11jGJjEEvaJfqtG2 jZ7N0ya5DPu3X1ra83N+w3xtzKJjfK6mAqGMFi3ZfbwvnHzhuj7QJ7cLcJSRMJmLjT2Y B4XnKLdZa/5xCws7ZBQ8b6FfTf/AhCpvq74glN4xyilLkk29K24IGnbrH18O+HmRweYy XqCQnTtf0T/srB6cA0NqiY4I5igCIk5SRnssghEqvSoxwFOABqTgfUm9IPk2Kod2tw6L Mk2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780690749; x=1781295549; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=fEynX1/cef0pndZEPm8gcDuGDO9NpbMBOZFQHs0cVw4=; b=m02qSZq7oQIKe+feCV+D0oBJ5tdn70Bk+aAIwdnab4NAwBdYW1MN7i+tEOe565OmMg AEsQDjooAm4FHJmxHrEzHF8aUwTRQR4cgEdQl6UPl3FuC+51o2KcHn6unvIc5CgAP5YS xYWccup5qsKo8R5U5sZsxAugktd2Z0o677VRGs6xE1jWcGd3CX4Q7g+P6P0WyeY8y4sy HWfB8irtmive3K+VrX6moBQqQlIhQ6wxeO80KXq+ECf+0Ot8CrwvATNZ3+HTOKvpHziJ nYSHK2P3NQ7lTtkGGhFJVnkzBU08ipdLrENjHzdYnrCBG3yMc1K6Cm51Aia9j8nyfKiT z27A== X-Forwarded-Encrypted: i=1; AFNElJ/GOAlUZDC3xzwtn9rh3HlTr2Srpi02qmfTKaQ8z9xPGgy3tCNG6Eqli8hgRU7fZbNhcIrF+SXrtQx8IUM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywsvtxgjc74mMFLsuSlAggLHGmAeDduz+kE4LgKtdBQHlBGYpS/ 1jrR9vq5PHGuLGugZ0JC9XMT63g4y5Us52MsLicCyPTt9VNcjh7A74MbFYw+mLtOIq6cAzz14J1 bLD7FEK0= X-Gm-Gg: Acq92OESH6PkZaUMymsVtRQtjnpv1bMWAfnslHgZCh9i8IxYVOzc3X+DXSen/3fWY9U WdGHnirai26rElvdxGHjDlVYlj2f/PUvZOOspHr/uDtrWLizm/gl5/9axb/K5bfKftFco7LuIDC gMi+/B8SKO6o2vtdP72jWdbO0HpEAxNcGSOnBkrlkMs9XhOm2z9rsmrjYVbsX3vGs5necE+6S3p nTeQK+p9TJ4VPb7Pdl2JfMGuhFKp93r/7d65daEmo9kbOaykeKXb00u2sIOHqWQZzVPp8NxEqqX 2uPFKKGjlWz1KPoxFhLZ6JWdH2qzzcdZcMFsV/i2XjR5HRXr+jf3JDYl2SxTx2UzNEHq3NJR7Kw c1qei1DkmYGe6Q/+7dr/QYSuj8k2ggOlklQ8+vvg6dwWB+uqssQK04BRwNrp89YoqwesmYgszFT pduIsIbWx9LobJ1aNfja+XRr4Keynximqn4FzUAXU3ywcp96sAjbVUMBnX24NxRqVYsyd48vFep cv0TOWzDurdbUl4x/BGY7vh3PQ= X-Received: by 2002:a05:600c:4506:b0:490:4973:91a0 with SMTP id 5b1f17b1804b1-490c25c0bd7mr90063925e9.10.1780690749367; Fri, 05 Jun 2026 13:19:09 -0700 (PDT) Received: from [127.0.1.1] ([94.4.195.193]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc413541sm190533895e9.14.2026.06.05.13.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 13:19:09 -0700 (PDT) From: Alexey Klimov Date: Fri, 05 Jun 2026 21:18:51 +0100 Subject: [PATCH 2/3] soc: samsung: exynos-pmu: fix use-after-free of interrupt generator node Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-2-0cd05c81a82d@linaro.org> References: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-0-0cd05c81a82d@linaro.org> In-Reply-To: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-0-0cd05c81a82d@linaro.org> To: Krzysztof Kozlowski , Alim Akhtar , Peter Griffin Cc: Sam Protsenko , linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Sashiko X-Mailer: b4 0.14.3 The setup_cpuhp_and_cpuidle() parses the device tree node for the interrupt generation block via of_parse_phandle() and decrements its reference count using of_node_put() immediately after fetching the resource address. However, later the intr_gen_node pointer is passed into of_syscon_register_regmap(). Fix this by moving the of_node_put() invocation to after the of_syscon_register_regmap() call, and adding it to correct error paths. Reported-by: Sashiko Closes: https://sashiko.dev/#/patchset/20260513-exynos850-cpuhotplug-v4-0-5= 4fec5f65362@linaro.org?part=3D3 Fixes: 78b72897a5c8 ("soc: samsung: exynos-pmu: Enable CPU Idle for gs101") Cc: stable@vger.kernel.org Signed-off-by: Alexey Klimov --- drivers/soc/samsung/exynos-pmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-= pmu.c index 6e635872247a..9636287f6794 100644 --- a/drivers/soc/samsung/exynos-pmu.c +++ b/drivers/soc/samsung/exynos-pmu.c @@ -428,23 +428,30 @@ static int setup_cpuhp_and_cpuidle(struct device *dev) * syscon provided regmap. */ ret =3D of_address_to_resource(intr_gen_node, 0, &intrgen_res); - of_node_put(intr_gen_node); + if (ret) { + of_node_put(intr_gen_node); + return ret; + } =20 virt_addr =3D devm_ioremap(dev, intrgen_res.start, resource_size(&intrgen_res)); - if (!virt_addr) + if (!virt_addr) { + of_node_put(intr_gen_node); return -ENOMEM; + } =20 pmu_context->pmuintrgen =3D devm_regmap_init_mmio(dev, virt_addr, ®map_pmu_intr); if (IS_ERR(pmu_context->pmuintrgen)) { dev_err(dev, "failed to initialize pmu-intr-gen regmap\n"); + of_node_put(intr_gen_node); return PTR_ERR(pmu_context->pmuintrgen); } =20 /* register custom mmio regmap with syscon */ ret =3D of_syscon_register_regmap(intr_gen_node, pmu_context->pmuintrgen); + of_node_put(intr_gen_node); if (ret) return ret; =20 --=20 2.51.0 From nobody Mon Jun 8 06:39:47 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14FAA43E9D2 for ; Fri, 5 Jun 2026 20:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780690755; cv=none; b=a0LQf5IlfPfyuZqGxaGzeCxrQC75RoyUmMG5/1penl/D9B0IbERlg0PVSdSOpijyjfXGn968GmxVrdUiKtrG6/GHdSPHr1bmGuVzWl5XN9xy8hjV92+U4Jfewp+yroRZ950cKSqID90gcIaOfKsfYdf8jowZ979XimzOrhaiEY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780690755; c=relaxed/simple; bh=HRCZhVoWK0niODWt+XbH4EjpgqnXLW23jOkUBvgIqgQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Xp3C795x51d+gfAxtvZKWCxBM1CpWaeROWYopo2WJeAV5iRgXOOtDnacR17z59H1SryJ9KmFIharBvEg6nuJgptWaNxMUvkNgk1gpdHp/FGWjzkG8qpG047RLrdMeEkVmSxcI9/RGqIfRsAqQnUIVYXrApJUBU0DhcUQVODV1NM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=sU5fyK5g; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sU5fyK5g" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490be03d47bso19334455e9.0 for ; Fri, 05 Jun 2026 13:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780690752; x=1781295552; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=POfwTOxPePIR+bzQ/YWTWSHHwFIOZT4YImIC9EJ68WE=; b=sU5fyK5gYcSzWubJr35fK1H0jTC4PhI3utTSRW1psYPWa4dMe5GduD5nwK1Vw6zvQZ uprW1ahtwIHLn0Dzlbrd14IA3QJzIEnjURC/nvxHizO+rCy8J4hqhk5JEMv/+JH4c9ri x9kNPVydvRsiT5nmO8YHbU4RYpwQ7h4HtVfBe+1esqI7J9cQ5cywUrxR/onbnisyJIvx hyQGSbLWDkLxKCXkFI0ogXt8gmOWnkuru87iV68P8/y9J8E/e6ojX4rcHSgpPHHW0yJT VCRDqtPboZcTLqe4BkIVCXCJNPxgTdUtoeLx1TwXLWH6C53YJZwNtVOOWO1oq3jsPxgv WV/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780690752; x=1781295552; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=POfwTOxPePIR+bzQ/YWTWSHHwFIOZT4YImIC9EJ68WE=; b=qPhV51AAKuA5TQtVigzwiGbyqoo8ycpG4Qz2Bi7VBswfdItsIrZwirD0Aivye5n4vq Qmbj6q2BzF4q7RrnxqzcyTlYMmK1mE/ABScoz7+AjT0rhm7OduIuxTJSgDJ52FogaQnJ 8nK0CnGnh+NU/YHt80i/GI3J4kPtzRyjNhxXdepZ3DxCXEpX6HeiDPMevO1KLmX+oQeG Ykl7WpJP8PVIwoRAkB6ZuOvqF/av+HXgbK8NqpAdBPRS6w+GtGY6zjEeDz4Qr5+d8jvF RtE4tch+e1Msm31HNHT5JxLJKZj97UmH8KDy44ElOa85fyOryFVwf1aj6mZSJlbO69nJ nJ5Q== X-Forwarded-Encrypted: i=1; AFNElJ/uMvIklqFZt5hmoD1ggc5tMMJBsGnFDGrW0XWnUQTq5Yx73goNoLw772X8f+ffNne8Mo1gxNxaRVxtpiI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+GzNcAmYJrIPq/h7+uUCkcscny5KW+NPdv1MSDpPVHouCiWLo s0A9a4PP8cfWQzHvlXF67clj+Bn+mAuERQlmaPG8tke+eXODDbksY8Th5sS9SFvtbi0= X-Gm-Gg: Acq92OGJm+14i7Usl8Ys1e9WEjpwB+6ADITLYksBQe1N9sJ4Jr8wvNHPPokjBH0AMN7 CSte4wnIG1PxUF3AK61GiB4uzW/kQDpnn7L6vzrh4t6BRmfoE5qkeELTO2rhz44nWcAX9n0EHBm XjgVSJusktpElnIghovbWIc9KD71vmWXqUrh+N7OxCMxPIKoLVFSy8/6O1VaBO0VxTWszo/Wbcj 6wYMIsW1AWxx020GJ6ArrygM6zwLGOuxRK+hN8xxpogRqUMI3HM6Pn0IL/wxuITrW9lbxL7fWBb ZGOO1nhaPldAS2qNl+wQr7pZxHPYyEzFEznVblvXYUgQ/9t/UI3UNMojrFPa8HYi35rNUBSG2BL VVtOpP4TgDU0fFFB1BiTOGFdXdShwMv44ig0v2ax+dAVtJDN0cZ+vzKBPQzJl1aFb/DrnIr4UZa OJstEg2r4i8NM5Rsn64lta9GubDm/w3ijMtV8kigEVE016ySukKRsiEXqL5+r+VSRDyYSJAqE2R /rEEDQN318vP1w4YOF3b187Hb8= X-Received: by 2002:a05:600c:8705:b0:488:ac01:72de with SMTP id 5b1f17b1804b1-490c25898efmr107486035e9.5.1780690751755; Fri, 05 Jun 2026 13:19:11 -0700 (PDT) Received: from [127.0.1.1] ([94.4.195.193]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc413541sm190533895e9.14.2026.06.05.13.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 13:19:10 -0700 (PDT) From: Alexey Klimov Date: Fri, 05 Jun 2026 21:18:52 +0100 Subject: [PATCH 3/3] soc: samsung: exynos-pmu: fix error paths in cpuhotplug/idle states setup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-3-0cd05c81a82d@linaro.org> References: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-0-0cd05c81a82d@linaro.org> In-Reply-To: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-0-0cd05c81a82d@linaro.org> To: Krzysztof Kozlowski , Alim Akhtar , Peter Griffin Cc: Sam Protsenko , linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Sashiko X-Mailer: b4 0.14.3 The setup_cpuhp_and_cpuidle() initialisation sequence currently ignores the return values of cpuhp_setup_state(), cpu_pm_register_notifier(), and register_reboot_notifier(). If any of these registrations fail during probe() routine, the driver returns 0, leaving the driver partially configured. Furthermore, if anything after setup_cpuhp_and_cpuidle() fails in probe() routine, for instance devm_mfd_add_devices(), the probe() lacks an error path and leaves notifiers and cpu hotplug states registered. Introduce variables for the cpu hotplug state IDs in exynos_pmu_context struct, that should be initialised to CPUHP_INVALID by default. Check all return codes in setup_cpuhp_and_cpuidle(), and add an error path to remove registered states on failure. Finally, add destroy_cpuhp_and_cpuidle() helper to safely tear down notifiers and cpu hotplug states. Reported-by: Sashiko Closes: https://sashiko.dev/#/patchset/20260513-exynos850-cpuhotplug-v4-0-5= 4fec5f65362@linaro.org?part=3D3 Fixes: 78b72897a5c8 ("soc: samsung: exynos-pmu: Enable CPU Idle for gs101") Cc: stable@vger.kernel.org Signed-off-by: Alexey Klimov --- drivers/soc/samsung/exynos-pmu.c | 57 ++++++++++++++++++++++++++++++++++--= ---- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-= pmu.c index 9636287f6794..846313a28e9a 100644 --- a/drivers/soc/samsung/exynos-pmu.c +++ b/drivers/soc/samsung/exynos-pmu.c @@ -38,6 +38,8 @@ struct exynos_pmu_context { unsigned long *in_cpuhp; bool sys_insuspend; bool sys_inreboot; + int cpuhp_prepare_state; + int cpuhp_online_state; }; =20 void __iomem *pmu_base_addr; @@ -404,6 +406,17 @@ static struct notifier_block exynos_cpupm_reboot_nb = =3D { .notifier_call =3D exynos_cpupm_reboot_notifier, }; =20 +static void destroy_cpuhp_and_cpuidle(void) +{ + cpu_pm_unregister_notifier(&gs101_cpu_pm_notifier); + unregister_reboot_notifier(&exynos_cpupm_reboot_nb); + + if (pmu_context->cpuhp_prepare_state !=3D CPUHP_INVALID) + cpuhp_remove_state(pmu_context->cpuhp_prepare_state); + if (pmu_context->cpuhp_online_state !=3D CPUHP_INVALID) + cpuhp_remove_state(pmu_context->cpuhp_online_state); +} + static int setup_cpuhp_and_cpuidle(struct device *dev) { struct device_node *intr_gen_node; @@ -465,16 +478,42 @@ static int setup_cpuhp_and_cpuidle(struct device *dev) gs101_cpuhp_pmu_online(cpu); =20 /* register CPU hotplug callbacks */ - cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "soc/exynos-pmu:prepare", - gs101_cpuhp_pmu_online, NULL); + pmu_context->cpuhp_prepare_state =3D CPUHP_INVALID; + pmu_context->cpuhp_online_state =3D CPUHP_INVALID; =20 - cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "soc/exynos-pmu:online", - NULL, gs101_cpuhp_pmu_offline); + ret =3D cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "soc/exynos-pmu:prepare", + gs101_cpuhp_pmu_online, NULL); + if (ret < 0) + return ret; + + pmu_context->cpuhp_prepare_state =3D ret; + + ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "soc/exynos-pmu:online", + NULL, gs101_cpuhp_pmu_offline); + if (ret < 0) + goto clean_cpuhp_states; + + pmu_context->cpuhp_online_state =3D ret; =20 /* register CPU PM notifiers for cpuidle */ - cpu_pm_register_notifier(&gs101_cpu_pm_notifier); - register_reboot_notifier(&exynos_cpupm_reboot_nb); - return 0; + ret =3D cpu_pm_register_notifier(&gs101_cpu_pm_notifier); + if (ret) + goto clean_cpuhp_states; + + ret =3D register_reboot_notifier(&exynos_cpupm_reboot_nb); + if (!ret) + /* Success */ + return ret; + + cpu_pm_unregister_notifier(&gs101_cpu_pm_notifier); + +clean_cpuhp_states: + if (pmu_context->cpuhp_prepare_state !=3D CPUHP_INVALID) + cpuhp_remove_state(pmu_context->cpuhp_prepare_state); + if (pmu_context->cpuhp_online_state !=3D CPUHP_INVALID) + cpuhp_remove_state(pmu_context->cpuhp_online_state); + + return ret; } =20 static int exynos_pmu_probe(struct platform_device *pdev) @@ -548,8 +587,10 @@ static int exynos_pmu_probe(struct platform_device *pd= ev) =20 ret =3D devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, exynos_pmu_devs, ARRAY_SIZE(exynos_pmu_devs), NULL, 0, NULL); - if (ret) + if (ret) { + destroy_cpuhp_and_cpuidle(); return ret; + } =20 if (devm_of_platform_populate(dev)) dev_err(dev, "Error populating children, reboot and poweroff might not w= ork properly\n"); --=20 2.51.0