[PATCH kernel v2] pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window

Nathan Chancellor nathan at kernel.org
Tue Aug 9 02:48:55 AEST 2022


Hi Alexey,

This change is now in mainline as commit b1fc44eaa9ba
("pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window").

> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
> index b4981b651d9a..5d2c22aa34fb 100644
> --- a/arch/powerpc/kexec/file_load_64.c
> +++ b/arch/powerpc/kexec/file_load_64.c
> @@ -1038,6 +1038,48 @@ static int update_cpus_node(void *fdt)
>  	return ret;
>  }
>  
> +static int copy_property(void *fdt, int node_offset, const struct device_node *dn,
> +			 const char *propname)
> +{
> +	const void *prop, *fdtprop;
> +	int len = 0, fdtlen = 0, ret;
> +
> +	prop = of_get_property(dn, propname, &len);
> +	fdtprop = fdt_getprop(fdt, node_offset, propname, &fdtlen);
> +
> +	if (fdtprop && !prop)
> +		ret = fdt_delprop(fdt, node_offset, propname);
> +	else if (prop)
> +		ret = fdt_setprop(fdt, node_offset, propname, prop, len);
> +
> +	return ret;
> +}

clang now warns/errors:

  arch/powerpc/kexec/file_load_64.c:1053:11: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
          else if (prop)
                  ^~~~
  arch/powerpc/kexec/file_load_64.c:1056:9: note: uninitialized use occurs here
          return ret;
                ^~~
  arch/powerpc/kexec/file_load_64.c:1053:7: note: remove the 'if' if its condition is always true
          else if (prop)
              ^~~~~~~~~
  arch/powerpc/kexec/file_load_64.c:1046:30: note: initialize the variable 'ret' to silence this warning
          int len = 0, fdtlen = 0, ret;
                                      ^
                                      = 0
  1 error generated.

Is !fdtprop && !prop a concern? What should a sensible default for ret
be?

Cheers,
Nathan


More information about the Linuxppc-dev mailing list