Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/kexec: Fix build failure from uninitialised variable

clang 14 won't build because ret is uninitialised and can be returned if
both prop and fdtprop are NULL. Drop the ret variable and return an
error in that failure case.

Fixes: b1fc44eaa9ba ("pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window")
Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220810054331.373761-1-ruscur@russell.cc

authored by

Russell Currey and committed by
Michael Ellerman
83ee9f23 59bab33a

+5 -5
+5 -5
arch/powerpc/kexec/file_load_64.c
··· 1043 1043 const char *propname) 1044 1044 { 1045 1045 const void *prop, *fdtprop; 1046 - int len = 0, fdtlen = 0, ret; 1046 + int len = 0, fdtlen = 0; 1047 1047 1048 1048 prop = of_get_property(dn, propname, &len); 1049 1049 fdtprop = fdt_getprop(fdt, node_offset, propname, &fdtlen); 1050 1050 1051 1051 if (fdtprop && !prop) 1052 - ret = fdt_delprop(fdt, node_offset, propname); 1052 + return fdt_delprop(fdt, node_offset, propname); 1053 1053 else if (prop) 1054 - ret = fdt_setprop(fdt, node_offset, propname, prop, len); 1055 - 1056 - return ret; 1054 + return fdt_setprop(fdt, node_offset, propname, prop, len); 1055 + else 1056 + return -FDT_ERR_NOTFOUND; 1057 1057 } 1058 1058 1059 1059 static int update_pci_dma_nodes(void *fdt, const char *dmapropname)