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] [thread-next>] [day] [month] [year] [list]
Message-ID: <ad422aebf347059c7dbdaee5a13d2d98093b77ca.camel@collabora.com>
Date: Tue, 24 Sep 2024 15:32:47 +0100
From: Martyn Welch <martyn.welch@...labora.com>
To: Markus Elfring <Markus.Elfring@....de>,
 linux-remoteproc@...r.kernel.org,  Andrew Davis	 <afd@...com>, Bjorn
 Andersson <andersson@...nel.org>, Hari Nagalla	 <hnagalla@...com>, Mathieu
 Poirier <mathieu.poirier@...aro.org>, Suman Anna	 <s-anna@...com>, Wadim
 Egorov <w.egorov@...tec.de>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org, 
 Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: Re: [PATCH] remoteproc: k3: Call of_node_put(rmem_np) only once in
 three functions

On Tue, 2024-09-24 at 14:43 +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Tue, 24 Sep 2024 14:28:35 +0200
> 
> An of_node_put(rmem_np) call was immediately used after a pointer
> check
> for a of_reserved_mem_lookup() call in three function
> implementations.
> Thus call such a function only once instead directly before the
> checks.
> 
> This issue was transformed by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>

reviewed-by: Martyn Welch <martyn.welch@...labora.com>

> ---
>  drivers/remoteproc/ti_k3_dsp_remoteproc.c | 6 ++----
>  drivers/remoteproc/ti_k3_m4_remoteproc.c  | 6 ++----
>  drivers/remoteproc/ti_k3_r5_remoteproc.c  | 3 +--
>  3 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c
> b/drivers/remoteproc/ti_k3_dsp_remoteproc.c
> index 8be3f631c192..d08a3a98ada1 100644
> --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c
> +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c
> @@ -576,11 +576,9 @@ static int k3_dsp_reserved_mem_init(struct
> k3_dsp_rproc *kproc)
>  			return -EINVAL;
> 
>  		rmem = of_reserved_mem_lookup(rmem_np);
> -		if (!rmem) {
> -			of_node_put(rmem_np);
> -			return -EINVAL;
> -		}
>  		of_node_put(rmem_np);
> +		if (!rmem)
> +			return -EINVAL;
> 
>  		kproc->rmem[i].bus_addr = rmem->base;
>  		/* 64-bit address regions currently not supported */
> diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c
> b/drivers/remoteproc/ti_k3_m4_remoteproc.c
> index 09f0484a90e1..a16fb165fced 100644
> --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c
> +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c
> @@ -433,11 +433,9 @@ static int k3_m4_reserved_mem_init(struct
> k3_m4_rproc *kproc)
>  			return -EINVAL;
> 
>  		rmem = of_reserved_mem_lookup(rmem_np);
> -		if (!rmem) {
> -			of_node_put(rmem_np);
> -			return -EINVAL;
> -		}
>  		of_node_put(rmem_np);
> +		if (!rmem)
> +			return -EINVAL;
> 
>  		kproc->rmem[i].bus_addr = rmem->base;
>  		/* 64-bit address regions currently not supported */
> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c
> b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> index 747ee467da88..d0ebdd5cfa70 100644
> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> @@ -1001,12 +1001,11 @@ static int k3_r5_reserved_mem_init(struct
> k3_r5_rproc *kproc)
>  		}
> 
>  		rmem = of_reserved_mem_lookup(rmem_np);
> +		of_node_put(rmem_np);
>  		if (!rmem) {
> -			of_node_put(rmem_np);
>  			ret = -EINVAL;
>  			goto unmap_rmem;
>  		}
> -		of_node_put(rmem_np);
> 
>  		kproc->rmem[i].bus_addr = rmem->base;
>  		/*
> --
> 2.46.1
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ