mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Gu Bin <gubin@cmss.chinamobile.com>
Cc: andrew@codeconstruct.com.au, avifishman70@gmail.com,
	tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com,
	yuenn@google.com, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwrng: npcm - use pm_runtime_resume_and_get() in npcm_rng_read()
Date: Fri, 20 Nov 2026 17:50:57 +0800	[thread overview]
Message-ID: <awAYAa1OY4_kk_Bg@gondor.apana.org.au> (raw)
In-Reply-To: <20261111073309.1659-1-gubin@cmss.chinamobile.com>

On Wed, Nov 11, 2026 at 03:33:08PM +0800, Gu Bin wrote:
> npcm_rng_read() calls pm_runtime_get_sync() without checking the return
> value and then polls and reads the RNG registers: when resuming the
> device fails (negative return), the loop reads a device that never
> resumed and the failure is lost - the function returns the (zero) byte
> count instead of an error.
> 
> Use pm_runtime_resume_and_get() instead and bail out on the error: the
> helper reports the resume failure and drops the usage counter reference
> it took, which a failed pm_runtime_get_sync() leaves behind (the usage
> counter is incremented before the resume attempt, so returning
> directly after a failed get_sync() would leak the reference and the
> device could never autosuspend again). The tail
> pm_runtime_put_sync_autosuspend() must not be used for this bailout:
> the device never resumed, so balancing the counter is all that is
> needed. On success the helper returns 0, which is exactly what the
> read counter expects at that point.
> 
> Fixes: c98429297d8b ("hwrng: npcm - add NPCM RNG driver")
> Signed-off-by: Gu Bin <gubin@cmss.chinamobile.com>
> ---
>  drivers/char/hw_random/npcm-rng.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2026-11-20  9:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  7:33 Gu Bin
2026-11-20  9:50 ` Herbert Xu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awAYAa1OY4_kk_Bg@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=andrew@codeconstruct.com.au \
    --cc=avifishman70@gmail.com \
    --cc=gubin@cmss.chinamobile.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tali.perry1@gmail.com \
    --cc=tmaimon77@gmail.com \
    --cc=venture@google.com \
    --cc=yuenn@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®