LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/kexec: Fix build failure from uninitialised variable
@ 2022-08-09  5:45 Russell Currey
  2022-08-09 10:52 ` Christophe Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Russell Currey @ 2022-08-09  5:45 UTC (permalink / raw)
  To: linuxppc-dev, aik; +Cc: nathan, Russell Currey

clang 14 won't build because ret is uninitialised and can be returned if
both prop and fdtprop are NULL.

Fixes: b1fc44eaa9ba ("pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window")
Signed-off-by: Russell Currey <ruscur@russell.cc>
---
Not sure what should be returned here, EINVAL seemed reasonable for a
passed property not existing.

Also, damn it Alexey, I mentioned this in my review:
http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20220616075901.835871-1-aik@ozlabs.ru/

Consider yourself lucky I'm no longer your dictator (if you don't already)

 arch/powerpc/kexec/file_load_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index 683462e4556b..8fa2995e6fc7 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -1043,7 +1043,7 @@ static int copy_property(void *fdt, int node_offset, const struct device_node *d
 			 const char *propname)
 {
 	const void *prop, *fdtprop;
-	int len = 0, fdtlen = 0, ret;
+	int len = 0, fdtlen = 0, ret = -EINVAL;
 
 	prop = of_get_property(dn, propname, &len);
 	fdtprop = fdt_getprop(fdt, node_offset, propname, &fdtlen);
-- 
2.37.1


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

* Re: [PATCH] powerpc/kexec: Fix build failure from uninitialised variable
  2022-08-09  5:45 [PATCH] powerpc/kexec: Fix build failure from uninitialised variable Russell Currey
@ 2022-08-09 10:52 ` Christophe Leroy
  0 siblings, 0 replies; 2+ messages in thread
From: Christophe Leroy @ 2022-08-09 10:52 UTC (permalink / raw)
  To: Russell Currey, linuxppc-dev@lists.ozlabs.org, aik@ozlabs.ru
  Cc: nathan@kernel.org



Le 09/08/2022 à 07:45, Russell Currey a écrit :
> clang 14 won't build because ret is uninitialised and can be returned if
> both prop and fdtprop are NULL.
> 
> Fixes: b1fc44eaa9ba ("pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window")
> Signed-off-by: Russell Currey <ruscur@russell.cc>
> ---
> Not sure what should be returned here, EINVAL seemed reasonable for a
> passed property not existing.

Not sure. My understanding is that fdt_delprop() and fdt_setprop() 
return one of the FDT_ERR_ defined in scripts/dtc/libfdt/libfdt.h

> 
> Also, damn it Alexey, I mentioned this in my review:
> http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20220616075901.835871-1-aik@ozlabs.ru/
> 
> Consider yourself lucky I'm no longer your dictator (if you don't already)
> 
>   arch/powerpc/kexec/file_load_64.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
> index 683462e4556b..8fa2995e6fc7 100644
> --- a/arch/powerpc/kexec/file_load_64.c
> +++ b/arch/powerpc/kexec/file_load_64.c
> @@ -1043,7 +1043,7 @@ static int copy_property(void *fdt, int node_offset, const struct device_node *d
>   			 const char *propname)
>   {
>   	const void *prop, *fdtprop;
> -	int len = 0, fdtlen = 0, ret;
> +	int len = 0, fdtlen = 0, ret = -EINVAL;

Do we need 'ret' at all ?

It would be more clear to return directly instead of going through a 
local var :

	if (fdtprop && !prop)
		return fdt_delprop(fdt, node_offset, propname);
	else if (prop)
		return fdt_setprop(fdt, node_offset, propname, prop, len);
	else
		return -FDT_ERR_NOTFOUND;


>   
>   	prop = of_get_property(dn, propname, &len);
>   	fdtprop = fdt_getprop(fdt, node_offset, propname, &fdtlen);

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

end of thread, other threads:[~2022-08-09 10:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-09  5:45 [PATCH] powerpc/kexec: Fix build failure from uninitialised variable Russell Currey
2022-08-09 10:52 ` Christophe Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox