lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <864j7gzvzx.wl-maz@kernel.org>
Date: Mon, 19 Aug 2024 10:45:38 +0100
From: Marc Zyngier <maz@...nel.org>
To: Ma Ke <make24@...as.ac.cn>
Cc: tglx@...utronix.de,
	Suravee.Suthikulpanit@....com,
	akpm@...ux-foundation.org,
	linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	stable@...r.kernel.org
Subject: Re: [PATCH] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init

On Mon, 19 Aug 2024 10:10:11 +0100,
Ma Ke <make24@...as.ac.cn> wrote:
> 
> Add the missing of_node_put() to release the refcount incremented
> by of_find_matching_node().
> 
> Cc: stable@...r.kernel.org
> Fixes: 4266ab1a8ff5 ("irqchip/gic-v2m: Refactor to prepare for ACPI support")
> Signed-off-by: Ma Ke <make24@...as.ac.cn>
> ---
>  drivers/irqchip/irq-gic-v2m.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
> index 51af63c046ed..65a55ee7bb30 100644
> --- a/drivers/irqchip/irq-gic-v2m.c
> +++ b/drivers/irqchip/irq-gic-v2m.c
> @@ -396,6 +396,7 @@ static int __init gicv2m_of_init(struct fwnode_handle *parent_handle,
>  		ret = of_address_to_resource(child, 0, &res);
>  		if (ret) {
>  			pr_err("Failed to allocate v2m resource.\n");
> +			of_node_put(child);
>  			break;
>  		}
>  

Although this indeed fixes a minor issue, it is probably better to
unify all the failure conditions. Something like this (untested):

diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 51af63c046ed..d5988012eb40 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -407,12 +407,12 @@ static int __init gicv2m_of_init(struct fwnode_handle *parent_handle,
 
 		ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis,
 				      &res, 0);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			break;
-		}
 	}
 
+	if (ret && child)
+		of_put_node(child);
 	if (!ret)
 		ret = gicv2m_allocate_domains(parent);
 	if (ret)


Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ