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>,
	stable@vger.kernel.org
Subject: [PATCH 1/2] virt: fsl: fix missing of_node_put() on early exit from for_each_compatible_node()
Date: Mon, 28 Oct 2024 18:05:41 +0100	[thread overview]
Message-ID: <20241028-fsl_hypervisor-of_node_put-v1-1-dd0621341fb7@gmail.com> (raw)
In-Reply-To: <20241028-fsl_hypervisor-of_node_put-v1-0-dd0621341fb7@gmail.com>

Early exits from for_each_compatible_node() require explicit calls to
of_node_put() to release the node and avoid leaking the resource. Add
the missing call to of_node_put(np) before the 'goto' instruction that
jumps out of the loop.

Cc: stable@vger.kernel.org
Fixes: 6db7199407ca ("drivers/virt: introduce Freescale hypervisor management driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/virt/fsl_hypervisor.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index e92e2ceb12a4..7c7ec13761ba 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -846,8 +846,10 @@ static int __init fsl_hypervisor_init(void)
 		}
 
 		dbisr = kzalloc(sizeof(*dbisr), GFP_KERNEL);
-		if (!dbisr)
+		if (!dbisr) {
+			of_node_put(np);
 			goto out_of_memory;
+		}
 
 		dbisr->irq = irq;
 		dbisr->doorbell = be32_to_cpup(handle);

-- 
2.43.0


  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] " Javier Carrasco
2024-10-28 17:05 ` Javier Carrasco [this message]
2024-10-28 17:05 ` [PATCH 2/2] virt: fsl: refactor out_of_memory label Javier Carrasco

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-1-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=stable@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®