Received: by 10.192.245.15 with SMTP id i15csp1082492imn; Sun, 11 Mar 2018 00:19:13 -0800 (PST) X-Google-Smtp-Source: AG47ELvM8qEyXzTz0bcvQuM/B29Qoi3+HEE9uPZFg+5NC57plIV7cMUZCjA78NrT4gnoH9v8UPIy X-Received: by 10.98.152.205 with SMTP id d74mr4186634pfk.115.1520756353556; Sun, 11 Mar 2018 00:19:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520756353; cv=none; d=google.com; s=arc-20160816; b=AWxKtD5d8jktD74EL8y/RVvhplsi8QwCIfN2MnpdGhaPy8MLe4PWb1elcitPI2ZQh6 JMZe5qBEyjx7r97kIWLeiyoBAQ8lEsoiT4f78759AcZFi4avg1ABjfFftpSD8Jx2U15q 3EVuT7syZTfi/GQxnLLBuJPk6wC4lLPFYLMz1NIPWbELufUQvEH/mQsXtUF3O7/QM5D/ 1HoMbKkb+UlLKIfr2KDeo52YfYzAPXyOx+mcmbdYUcEaP7QaaPPqGkopE8dCNpuiLGz0 X9ZLThxb2t0QByK/xne8HjqOvr8r52ox2kOdWrwBX4PN3D8ZTzsP72OEtlLxtIB2DrA0 ldAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id:cc:subject :from:to:arc-authentication-results; bh=1GcKuxJGLUEI3ddJbw2TEa1BCgEDBA5IV0GvazFn/08=; b=nHIi4ppgv5jshFhGOTsLcfxZcii5PPxHfa8cth57D14p5jJP95D/Ilo8Fnwc2gaeF5 6LqZ7YdiFBEJ/X9ZFiLv58llor5c7+uzsR9JK5gBbk47JsmHW1VOBY4Vf9hZVscNC1MB 5QlNg8uREjAxCsWw8Uh7vEQ5z81C727LEC4VE2WKECVwibioPVAU+yI4A+f7taILigs8 adgLJG/gS2IilVjgMKMxwwDpkNHIaukEZW4DUz3n0/VBYuVOns6cxT2DdylO7wN5vvR9 1pfGqmn42TyKxlTleSVUwBYJXYo5uhIch7XGFQG/eqNuuIbiuTVwSa1f4zhDHO0oNs95 W6KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y4-v6si66132pll.413.2018.03.11.00.18.48; Sun, 11 Mar 2018 00:19:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932136AbeCKIRS (ORCPT + 99 others); Sun, 11 Mar 2018 04:17:18 -0400 Received: from mout.web.de ([217.72.192.78]:45959 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932093AbeCKIRQ (ORCPT ); Sun, 11 Mar 2018 04:17:16 -0400 Received: from [192.168.1.2] ([77.182.27.43]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MWB8f-1fAX3Y19YX-00XMFQ; Sun, 11 Mar 2018 09:16:57 +0100 To: linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , Borislav Petkov , Brijesh Singh , Josh Sklar , Kees Cook , Michael Ellerman , Paul Mackerras , Thiago Jung Bauermann , Thomas Gleixner , Tom Lendacky From: SF Markus Elfring Subject: [PATCH] powerpc: Use common error handling code in setup_new_fdt() Cc: LKML , kernel-janitors@vger.kernel.org Message-ID: <0dd9d938-8d89-f0e0-f05f-9a3e5dc42a57@users.sourceforge.net> Date: Sun, 11 Mar 2018 09:16:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:8BWavJHWazl5IkpgzQ6ewok6qzGaEIAwf6UzDQjs+lkOJKQrN/v j/DezU+n1Ka9xaXtGyp2EJntQ+kdtEFIFgSlDCi7yB1v1loze0nfC0BFdXL+JXKWtH5sdfC RVMkCobMUMOWtgW+X4HaFjoB55+9b0w9ok+eY75VktiRU4T3zuiKq9IZg+7R3k4nlMAaNGJ T7B2UlOIIX7QSyi6KDHHA== X-UI-Out-Filterresults: notjunk:1;V01:K0:BgNqwrkyNSo=:pHwko/8qCX4MfL1v8fsMvm wR4gr07CqF0nE8tb1qIS3LaIvooTKxHbF2Cs4cvKJzmyEL9exfgr/+zCL8EEiztyUM8cysztL BbVthmB8ury7gfooKaLqAtdPomvqi47UMzQyR7JfuH9Dyxpb9g9Z4NpbdohgWeNgpnpEBLeKL 3Qm9mBxGbfvRjCg+Gi3TY9tWe3KumEwdjeQkleSnGZc+dxbGyF3ek1CGJUC8FmmohrP6XPEYB xbTGFtNLVVqQzpjUM5qE0r5YLFRvDv3ALw98XRHnQj259D2qIVGpB9RT02/c8jBgMBqLbhAcS NO8xRAqdnSib9UOQw//ZfxeaxPyX/Hit46hfi104J/kIWydeTjDdvhnI+gr967gNs1VmAuFAA jNkqftyh5EXrcQy3TjdIWxIcPtTtrnSG2MOMbBYY/a1ZN6ZW7zVl9IxfiB1rv0NqtJMjqUeyl BS9rokgteC8N9r+LVxm0o384eQRdzKwitaMOPFI97AzmsLVHdQ4zN3Y6H1+Eqiqg3UIuMImRW zmma3FxngkJyumpoI3Epo2/1H733/oQmlm8SGlBpPiOug6/kaCx3zMea8kK4DCqlB+IJREgfx OjvLr1Sj0OclE8BzUHp5VFFyRW4iepKLP8r/+/29x0WEiliwz5S+rCAT+BjgQgjZ2iDZ8TJYH +UlB7I+6Cv7XPHt6fohUaywMswSvlcQwGdlYu7VMB98eCUXxubtl9pwc38nco4vV9biiq1+la ORf3kPY9jyFBDPQKMqtmQr51kw6VlawNmBzJxa42E8QFf9xkZ0jpR94UFzV7/fm7Vt6kufcDG aMmNq9xX/4L69QeILJEgy3nDrYD+sCDPzydQ1mwT6s/ErJd10g= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sun, 11 Mar 2018 09:03:42 +0100 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 --- arch/powerpc/kernel/machine_kexec_file_64.c | 28 ++++++++++++---------------- 1 file 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 e4395f937d63..90c6004c2eec 100644 --- a/arch/powerpc/kernel/machine_kexec_file_64.c +++ b/arch/powerpc/kernel/machine_kexec_file_64.c @@ -302,18 +302,14 @@ int setup_new_fdt(const struct kimage *image, void *fdt, ret = fdt_setprop_u64(fdt, chosen_node, "linux,initrd-start", initrd_load_addr); - if (ret < 0) { - pr_err("Error setting up the new device tree.\n"); - return -EINVAL; - } + if (ret < 0) + goto report_setup_failure; /* initrd-end is the first address after the initrd image. */ ret = fdt_setprop_u64(fdt, chosen_node, "linux,initrd-end", initrd_load_addr + initrd_len); - if (ret < 0) { - pr_err("Error setting up the new device tree.\n"); - return -EINVAL; - } + if (ret < 0) + goto report_setup_failure; ret = fdt_add_mem_rsv(fdt, initrd_load_addr, initrd_len); if (ret) { @@ -325,10 +321,8 @@ int setup_new_fdt(const struct kimage *image, void *fdt, if (cmdline != NULL) { ret = fdt_setprop_string(fdt, chosen_node, "bootargs", cmdline); - if (ret < 0) { - pr_err("Error setting up the new device tree.\n"); - return -EINVAL; - } + if (ret < 0) + goto report_setup_failure; } else { ret = fdt_delprop(fdt, chosen_node, "bootargs"); if (ret && ret != -FDT_ERR_NOTFOUND) { @@ -344,10 +338,12 @@ int setup_new_fdt(const struct kimage *image, void *fdt, } ret = fdt_setprop(fdt, chosen_node, "linux,booted-from-kexec", NULL, 0); - if (ret) { - pr_err("Error setting up the new device tree.\n"); - return -EINVAL; - } + if (ret) + goto report_setup_failure; return 0; + +report_setup_failure: + pr_err("Error setting up the new device tree.\n"); + return -EINVAL; } -- 2.16.2