mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>, Timur Tabi <timur@freescale.com>,
	 Kumar Gala <galak@kernel.crashing.org>
Cc: linux-kernel@vger.kernel.org,
	 Javier Carrasco <javier.carrasco.cruz@gmail.com>
Subject: [PATCH 2/2] virt: fsl: refactor out_of_memory label
Date: Mon, 28 Oct 2024 18:05:42 +0100	[thread overview]
Message-ID: <20241028-fsl_hypervisor-of_node_put-v1-2-dd0621341fb7@gmail.com> (raw)
In-Reply-To: <20241028-fsl_hypervisor-of_node_put-v1-0-dd0621341fb7@gmail.com>

The 'out_of_memory' label is only accessible by means of a goto jump
that only happens once. Take the required actions right after the error
happens, and drop the need for a jump out of the loop.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/virt/fsl_hypervisor.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index 7c7ec13761ba..bc5d7aa246df 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -848,7 +848,13 @@ static int __init fsl_hypervisor_init(void)
 		dbisr = kzalloc(sizeof(*dbisr), GFP_KERNEL);
 		if (!dbisr) {
 			of_node_put(np);
-			goto out_of_memory;
+			list_for_each_entry_safe(dbisr, n, &isr_list, list) {
+				free_irq(dbisr->irq, dbisr);
+				list_del(&dbisr->list);
+				kfree(dbisr);
+			}
+			misc_deregister(&fsl_hv_misc_dev);
+			return -ENOMEM;
 		}
 
 		dbisr->irq = irq;
@@ -895,17 +901,6 @@ static int __init fsl_hypervisor_init(void)
 	}
 
 	return 0;
-
-out_of_memory:
-	list_for_each_entry_safe(dbisr, n, &isr_list, list) {
-		free_irq(dbisr->irq, dbisr);
-		list_del(&dbisr->list);
-		kfree(dbisr);
-	}
-
-	misc_deregister(&fsl_hv_misc_dev);
-
-	return -ENOMEM;
 }
 
 /*

-- 
2.43.0


      parent reply	other threads:[~2024-10-28 17:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-28 17:05 [PATCH 0/2] virt: fsl: fix missing of_node_put() on early exit from for_each_compatible_node() Javier Carrasco
2024-10-28 17:05 ` [PATCH 1/2] " Javier Carrasco
2024-10-28 17:05 ` Javier Carrasco [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=20241028-fsl_hypervisor-of_node_put-v1-2-dd0621341fb7@gmail.com \
    --to=javier.carrasco.cruz@gmail.com \
    --cc=arnd@arndb.de \
    --cc=galak@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=timur@freescale.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®