From nobody Tue Sep 29 11:19:23 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 BF2031AA1D5 for ; Sat, 8 Aug 2026 07:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786173935; cv=none; b=E54FyL9OyyZJgFqEtmm9lLEvWJUo5w0B/CCnddFLFynLXxmqXqMPY+WxX6Q1bBRQcZO4lDK81Pp15/z7zxpI9QuQ+HlWTzn6Tz6Mmn/5w79409qfchQbMubl3Xx/kiE4zrF4hQ5f9NUGPoU/oldj74sugPMXq7t/RrEz7f2QjtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786173935; c=relaxed/simple; bh=G1BNkX7MmoPkXUOj12zHxbfv+qVUKXjsfvBuX8CZIpg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PnTbr+5NmrirpRvXT9oWKL7PrGRna5va8JXQjU/wko4T0ny9nhBhvmXib9ze1GResU/n5Ky3TLELMF2Fm1NpZjelf7EaA0r0FGS0lb5SST3p79Yp9Ss2ZwvGWgoYrei+im/quzu6bvDoXICQHGvrx0A1liz5fpieEk0Lv/RGNVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VIoltbUI; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VIoltbUI" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2cfff5f88dbso4985785ad.3 for ; Sat, 08 Aug 2026 00:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786173934; x=1786778734; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=CwYH+YDI8SAmi2VA+WwpQ0qieT+uWBICR9XfrxWBjvg=; b=VIoltbUIxZBN2xbH631/e9CVOlKJ50RupYU+JGJbnleLCmxbxoL/59T/N7UScnjGoZ kpIe4ao4VPWLhlXpERnEnuzcnptBrvjQAPwTSUrXK2Snqi4rs08HMPXQK6hGDAhjtet7 lYLcHH12MXVWsxWy0ghQ1DabicaC3TwSnqdxVY2xVAfNR/QgQt/O1445eg2E65CqIUKq VFkWtro+g2DnxcNLURf6+tjF8MBJdfXb4Mi3+nqAkZNO2Q9rfnt2c7e1H+sxIiaMSdya 4w1w7OfAQZlBX4St+tuPCfvBMKTQpwqgQKiwkOocn6MSpPzJE0G4EML8+HSZcwCsNuRH uV2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786173934; x=1786778734; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CwYH+YDI8SAmi2VA+WwpQ0qieT+uWBICR9XfrxWBjvg=; b=ZAZH5G6cg3YvpuRy084UlsA2Yty3En7ekG/T1GrxAbR6oEGKfDLH1AJ0Ta3KPBftYt O6S44fxkn1XbNEGigfOb5TL4AYJVJ5EzkAgwBB+s8i0eFuKacRpcMzByuw8aTmvlC9yx CQin+8NSQJts64fCXkngEhIfRI3xPOIzVmY0UuXU0Da5yh8vTZJy6yGD/I19XGHixg5i liTrdb9qt2ObVHH6bJOfjw7oU3uWqf75RlyvvTKUG6G9XRyDaqJNcxr0Z/uQpgfEP9FM MOTKdqahEJakjCYNoMdvt1jHTPd6E0MTrwKzuL2UacV/gmytP9A2e1w0pGpKMxw8I2AZ U6Zw== X-Forwarded-Encrypted: i=1; AHgh+RqXckbnQAX7qZoOkRVfX8jFArP2BaSFret3FpaN92vYCJFHg/ExVRlgNS9PnlhHMam+uEcWj7Td8S+2RsU=@vger.kernel.org X-Gm-Message-State: AOJu0YyObC4yOtoBu6pIGc47AACi8pjtU8sCDGUcUytc7eNlN4ggd4tA 3GbhW1//OUaDMF94vMWEkGaIjefgYD0+b2xW/pU4DFnWfd9p2NezsYrp X-Gm-Gg: AR+sD13ajoG6U//soLcVmZJ74QzdHcTklC95l72TCsjXDBIcB6yjUbcXcbmEEDhhbg2 JyU3KTTLRuqA0M5bvHK5FF4d00Rnr7dD/3KlHqGmtiUrI3cLSvlvOT/P6XNoWnRts3ZckTOv9v1 x0JOqLYyF7dYz3MNSX2u93lzjOvQD5RV4+SzMn+4/HzNUACGQ55OGDeF07pY+gXjGn0ABN1VVMm Y9kwpRQW2WlAr/Qdxw5xk2G2VInytaL7HZDgNfVlwODrqPkrSc4/y9mV7+TgqVLXE4h3PPBGdHq i13GeJWOI8jzAmm1kkDIqNxz8IA32tqJDPFtYj4zHi7ATl4mcwUoPc1GUovujkdwtAN1log1clI dFtFz1s2e/ZceXeh+0d9dbPt50ll3B/jhyaVzXwbZs6NpwfigFDZJsSnY/LIrxsTBbv04jf6FC4 rDPFdKuK5TCAU3aL1eOboz0OrObV7ko9ljjsDUkforFkUAg1DLkg== X-Received: by 2002:a17:902:ccd1:b0:2d1:1a28:10d with SMTP id d9443c01a7336-2d11a280465mr159732205ad.18.1786173934103; Sat, 08 Aug 2026 00:25:34 -0700 (PDT) Received: from lgs.. ([118.193.33.13]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d14ccadef6sm16578155ad.11.2026.08.08.00.25.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Aug 2026 00:25:33 -0700 (PDT) From: Guangshuo Li To: Jia Jie Ho , Olivia Mackall , Herbert Xu , Philipp Zabel , Jenny Zhang , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Guangshuo Li , stable@vger.kernel.org Subject: [PATCH] hwrng: starfive: fix runtime PM autosuspend cleanup Date: Sat, 8 Aug 2026 15:25:16 +0800 Message-ID: <20260808072516.2640658-1-lgs201920130244@gmail.com> X-Mailer: git-send-email 2.43.0 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" starfive_trng_probe() calls pm_runtime_use_autosuspend(), but runtime PM is enabled with pm_runtime_enable() without a corresponding pm_runtime_dont_use_autosuspend() during driver teardown. If the autosuspend delay is set to a negative value while autosuspend is enabled, the runtime PM core increments usage_count to prevent runtime suspend. Without undoing the autosuspend setting during teardown, this reference can remain unbalanced. Use devm_pm_runtime_enable() so that runtime PM and the autosuspend setting are automatically cleaned up on probe failure and device removal. Remove the explicit pm_runtime_disable() from the hwrng registration failure path since the managed cleanup handles it. This issue was found by manual code inspection. Fixes: c388f458bc34 ("hwrng: starfive - Add TRNG driver for StarFive SoC") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li --- drivers/char/hw_random/jh7110-trng.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/jh7110-trng.c b/drivers/char/hw_random/= jh7110-trng.c index 4712c3c530e4..34b2ec3e13b3 100644 --- a/drivers/char/hw_random/jh7110-trng.c +++ b/drivers/char/hw_random/jh7110-trng.c @@ -336,12 +336,18 @@ static int starfive_trng_probe(struct platform_device= *pdev) =20 pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 100); - pm_runtime_enable(&pdev->dev); + ret =3D devm_pm_runtime_enable(&pdev->dev); + if (ret) { + reset_control_assert(trng->rst); + clk_disable_unprepare(trng->ahb); + clk_disable_unprepare(trng->hclk); + + return dev_err_probe(&pdev->dev, ret, + "Failed to enable runtime PM\n"); + } =20 ret =3D devm_hwrng_register(&pdev->dev, &trng->rng); if (ret) { - pm_runtime_disable(&pdev->dev); - reset_control_assert(trng->rst); clk_disable_unprepare(trng->ahb); clk_disable_unprepare(trng->hclk); --=20 2.43.0