diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2018-03-11 04:03:42 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-08-10 08:12:36 -0400 |
commit | baedcdf5054c151a33e34392af7d8c3a244f16e6 (patch) | |
tree | 682140b0ec9ef2345bbe018c2b28d90e474aad19 | |
parent | 302c7b0c4ff5aed585419603f835dee30207e5d5 (diff) |
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: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/kernel/machine_kexec_file_64.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/arch/powerpc/kernel/machine_kexec_file_64.c b/arch/powerpc/kernel/machine_kexec_file_64.c index 0bd23dc789a4..c77e95e9b384 100644 --- a/arch/powerpc/kernel/machine_kexec_file_64.c +++ b/arch/powerpc/kernel/machine_kexec_file_64.c | |||
@@ -269,18 +269,14 @@ int setup_new_fdt(const struct kimage *image, void *fdt, | |||
269 | ret = fdt_setprop_u64(fdt, chosen_node, | 269 | ret = fdt_setprop_u64(fdt, chosen_node, |
270 | "linux,initrd-start", | 270 | "linux,initrd-start", |
271 | initrd_load_addr); | 271 | initrd_load_addr); |
272 | if (ret < 0) { | 272 | if (ret < 0) |
273 | pr_err("Error setting up the new device tree.\n"); | 273 | goto err; |
274 | return -EINVAL; | ||
275 | } | ||
276 | 274 | ||
277 | /* initrd-end is the first address after the initrd image. */ | 275 | /* initrd-end is the first address after the initrd image. */ |
278 | ret = fdt_setprop_u64(fdt, chosen_node, "linux,initrd-end", | 276 | ret = fdt_setprop_u64(fdt, chosen_node, "linux,initrd-end", |
279 | initrd_load_addr + initrd_len); | 277 | initrd_load_addr + initrd_len); |
280 | if (ret < 0) { | 278 | if (ret < 0) |
281 | pr_err("Error setting up the new device tree.\n"); | 279 | goto err; |
282 | return -EINVAL; | ||
283 | } | ||
284 | 280 | ||
285 | ret = fdt_add_mem_rsv(fdt, initrd_load_addr, initrd_len); | 281 | ret = fdt_add_mem_rsv(fdt, initrd_load_addr, initrd_len); |
286 | if (ret) { | 282 | if (ret) { |
@@ -292,10 +288,8 @@ int setup_new_fdt(const struct kimage *image, void *fdt, | |||
292 | 288 | ||
293 | if (cmdline != NULL) { | 289 | if (cmdline != NULL) { |
294 | ret = fdt_setprop_string(fdt, chosen_node, "bootargs", cmdline); | 290 | ret = fdt_setprop_string(fdt, chosen_node, "bootargs", cmdline); |
295 | if (ret < 0) { | 291 | if (ret < 0) |
296 | pr_err("Error setting up the new device tree.\n"); | 292 | goto err; |
297 | return -EINVAL; | ||
298 | } | ||
299 | } else { | 293 | } else { |
300 | ret = fdt_delprop(fdt, chosen_node, "bootargs"); | 294 | ret = fdt_delprop(fdt, chosen_node, "bootargs"); |
301 | if (ret && ret != -FDT_ERR_NOTFOUND) { | 295 | if (ret && ret != -FDT_ERR_NOTFOUND) { |
@@ -311,10 +305,12 @@ int setup_new_fdt(const struct kimage *image, void *fdt, | |||
311 | } | 305 | } |
312 | 306 | ||
313 | ret = fdt_setprop(fdt, chosen_node, "linux,booted-from-kexec", NULL, 0); | 307 | ret = fdt_setprop(fdt, chosen_node, "linux,booted-from-kexec", NULL, 0); |
314 | if (ret) { | 308 | if (ret) |
315 | pr_err("Error setting up the new device tree.\n"); | 309 | goto err; |
316 | return -EINVAL; | ||
317 | } | ||
318 | 310 | ||
319 | return 0; | 311 | return 0; |
312 | |||
313 | err: | ||
314 | pr_err("Error setting up the new device tree.\n"); | ||
315 | return -EINVAL; | ||
320 | } | 316 | } |