Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit baedcdf5 authored by Markus Elfring's avatar Markus Elfring Committed by Michael Ellerman
Browse files

powerpc/kexec: Use common error handling code in setup_new_fdt()



Add a jump target so that a bit of exception handling can be better
reused at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Reviewed-by: default avatarThiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 302c7b0c
Loading
Loading
Loading
Loading
+12 −16
Original line number Original line Diff line number Diff line
@@ -269,18 +269,14 @@ int setup_new_fdt(const struct kimage *image, void *fdt,
		ret = fdt_setprop_u64(fdt, chosen_node,
		ret = fdt_setprop_u64(fdt, chosen_node,
				      "linux,initrd-start",
				      "linux,initrd-start",
				      initrd_load_addr);
				      initrd_load_addr);
		if (ret < 0) {
		if (ret < 0)
			pr_err("Error setting up the new device tree.\n");
			goto err;
			return -EINVAL;
		}


		/* initrd-end is the first address after the initrd image. */
		/* initrd-end is the first address after the initrd image. */
		ret = fdt_setprop_u64(fdt, chosen_node, "linux,initrd-end",
		ret = fdt_setprop_u64(fdt, chosen_node, "linux,initrd-end",
				      initrd_load_addr + initrd_len);
				      initrd_load_addr + initrd_len);
		if (ret < 0) {
		if (ret < 0)
			pr_err("Error setting up the new device tree.\n");
			goto err;
			return -EINVAL;
		}


		ret = fdt_add_mem_rsv(fdt, initrd_load_addr, initrd_len);
		ret = fdt_add_mem_rsv(fdt, initrd_load_addr, initrd_len);
		if (ret) {
		if (ret) {
@@ -292,10 +288,8 @@ int setup_new_fdt(const struct kimage *image, void *fdt,


	if (cmdline != NULL) {
	if (cmdline != NULL) {
		ret = fdt_setprop_string(fdt, chosen_node, "bootargs", cmdline);
		ret = fdt_setprop_string(fdt, chosen_node, "bootargs", cmdline);
		if (ret < 0) {
		if (ret < 0)
			pr_err("Error setting up the new device tree.\n");
			goto err;
			return -EINVAL;
		}
	} else {
	} else {
		ret = fdt_delprop(fdt, chosen_node, "bootargs");
		ret = fdt_delprop(fdt, chosen_node, "bootargs");
		if (ret && ret != -FDT_ERR_NOTFOUND) {
		if (ret && ret != -FDT_ERR_NOTFOUND) {
@@ -311,10 +305,12 @@ int setup_new_fdt(const struct kimage *image, void *fdt,
	}
	}


	ret = fdt_setprop(fdt, chosen_node, "linux,booted-from-kexec", NULL, 0);
	ret = fdt_setprop(fdt, chosen_node, "linux,booted-from-kexec", NULL, 0);
	if (ret) {
	if (ret)
		pr_err("Error setting up the new device tree.\n");
		goto err;
		return -EINVAL;
	}


	return 0;
	return 0;

err:
	pr_err("Error setting up the new device tree.\n");
	return -EINVAL;
}
}