Skip to contentSkip to conversation

powerpc/kexec: Fix build failure from uninitialised variable

PATCH Applied Russell Currey 3 participants 3 messages Aug 10, 2022 – Aug 13, 2022 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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")

---
v2: adopt Christophe's suggestion, which is better

 arch/powerpc/kexec/file_load_64.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/powerpc/kexec/file_load_64.c +5 -5
index 683462e4556b..349a781cea0b 100644
@@ -1043,17 +1043,17 @@ 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;
 
 	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);
+		return fdt_delprop(fdt, node_offset, propname);
 	else if (prop)
-		ret = fdt_setprop(fdt, node_offset, propname, prop, len);
-
-	return ret;
+		return fdt_setprop(fdt, node_offset, propname, prop, len);
+	else
+		return -FDT_ERR_NOTFOUND;
 }
 
 static int update_pci_dma_nodes(void *fdt, const char *dmapropname)
Signature · 1 line
2.37.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Russell Currey

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")

Thanks for the patch!

Quoted 36 lines

---
v2: adopt Christophe's suggestion, which is better

 arch/powerpc/kexec/file_load_64.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/powerpc/kexec/file_load_64.c +5 -5
index 683462e4556b..349a781cea0b 100644
@@ -1043,17 +1043,17 @@ 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;
 
 	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);
+		return fdt_delprop(fdt, node_offset, propname);
 	else if (prop)
-		ret = fdt_setprop(fdt, node_offset, propname, prop, len);
-
-	return ret;
+		return fdt_setprop(fdt, node_offset, propname, prop, len);
+	else
+		return -FDT_ERR_NOTFOUND;
 }
 
 static int update_pci_dma_nodes(void *fdt, const char *dmapropname)
Signature · 1 line
2.37.1