All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwrng: amd - simplify control flow in amd_rng_mod_init()
@ 2026-10-02 14:19 Thorsten Blum
  2026-10-08  8:33 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-10-02 14:19 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu,
	Uwe Kleine-König (The Capable Hub), Kees Cook
  Cc: Thorsten Blum, linux-crypto, linux-kernel

Replace the goto found statement with a break and check pdev after the
loop. Also consolidate the cleanup paths.

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 drivers/char/hw_random/amd-rng.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c
index dff80daae587..a4c027dd8df2 100644
--- a/drivers/char/hw_random/amd-rng.c
+++ b/drivers/char/hw_random/amd-rng.c
@@ -129,19 +129,15 @@ static int __init amd_rng_mod_init(void)
 {
 	int err;
 	struct pci_dev *pdev = NULL;
-	const struct pci_device_id *ent;
 	u32 pmbase;
 	struct amd768_priv *priv;
 
-	for_each_pci_dev(pdev) {
-		ent = pci_match_id(pci_tbl, pdev);
-		if (ent)
-			goto found;
-	}
-	/* Device not found. */
-	return -ENODEV;
+	for_each_pci_dev(pdev)
+		if (pci_match_id(pci_tbl, pdev))
+			break;
+	if (!pdev)
+		return -ENODEV;
 
-found:
 	err = pci_read_config_dword(pdev, 0x58, &pmbase);
 	if (err) {
 		err = pcibios_err_to_errno(err);
@@ -171,7 +167,7 @@ static int __init amd_rng_mod_init(void)
 	if (!priv->iobase) {
 		pr_err(DRV_NAME "Cannot map ioport\n");
 		err = -EINVAL;
-		goto err_iomap;
+		goto err;
 	}
 
 	amd_rng.priv = (unsigned long)priv;
@@ -182,13 +178,12 @@ static int __init amd_rng_mod_init(void)
 	err = hwrng_register(&amd_rng);
 	if (err) {
 		pr_err(DRV_NAME " registering failed (%d)\n", err);
-		goto err_hwrng;
+		ioport_unmap(priv->iobase);
+		goto err;
 	}
 	return 0;
 
-err_hwrng:
-	ioport_unmap(priv->iobase);
-err_iomap:
+err:
 	release_region(pmbase + PMBASE_OFFSET, PMBASE_SIZE);
 out:
 	kfree(priv);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwrng: amd - simplify control flow in amd_rng_mod_init()
  2026-10-02 14:19 [PATCH] hwrng: amd - simplify control flow in amd_rng_mod_init() Thorsten Blum
@ 2026-10-08  8:33 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-10-08  8:33 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Olivia Mackall, Uwe Kleine-König (The Capable Hub),
	Kees Cook, linux-crypto, linux-kernel

On Fri, Oct 02, 2026 at 04:19:51PM +0200, Thorsten Blum wrote:
> Replace the goto found statement with a break and check pdev after the
> loop. Also consolidate the cleanup paths.
> 
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
>  drivers/char/hw_random/amd-rng.c | 23 +++++++++--------------
>  1 file changed, 9 insertions(+), 14 deletions(-)

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-08  8:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02 14:19 [PATCH] hwrng: amd - simplify control flow in amd_rng_mod_init() Thorsten Blum
2026-10-08  8:33 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.