From patchwork Wed Oct 16 20:00:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11194147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9342217E1 for ; Wed, 16 Oct 2019 20:03:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C31A20854 for ; Wed, 16 Oct 2019 20:03:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="m++yEVvO"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="VQjJFXBg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C31A20854 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=INX9OVYCt7+v2wS6IGz0oNm2xnbZMEoQKRMlHpPwOA0=; b=m++yEVvOBk57Le d0zkwNUJF/Jo+lEluMgcTXtoO4EhHnu2LvDVDr4axY8AEAtCBFUQQDLwA0dIRIpHfoss9hHr4yRVP 0UR6AmxjQjU2Oiijj233um8LmnkXtgMJ6LwkPKP8/ZwMzxrJVoGnPChlTnGqlnRABxBVrIeA62kcx 70//BFDKPrzsa4ngm/0iaVEUO4scyP+o0ff1PPzMn87li4OSPeOxFOqfVi0rGaMv6MtrMqm2s/EgU UjChqY7sC4TWXj5xXIrb30hm1JUqmwCjBSX+ObwbF+cy2wsbiHWN20ClmQTtt+KAlL/fWif6pKCwW 8FKwNGb7BgqDxTcGwO0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iKpWX-0006ke-Dg; Wed, 16 Oct 2019 20:03:57 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iKpTV-0004BY-VL for linux-arm-kernel@lists.infradead.org; Wed, 16 Oct 2019 20:00:52 +0000 Received: by mail-qk1-x742.google.com with SMTP id w2so24004773qkf.2 for ; Wed, 16 Oct 2019 13:00:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=54zhWvY2wVoS8DJjdyrocZPF+2/4Isg+VJgEApzMseg=; b=VQjJFXBgIgXw9ArhBGE5FQdjnAyrw85fgXHavYyEVvr/1RLZMNuDVk5bbNdZcIF01O 35K3GcvDVMDbUHK0atzpOyVj1bnP2ahysMefdRQyZT7RNeMYNKsTQdbY7H889PYrunrA byHCuUtEBXE9ebvHhThbdXWFgWz79nt7Ls87mfshUdegvoSErZvOsTSKjNu/LwqOSFlo 9yUmGZ7PqYMUWTTNbdAJdDnjaFu2xo/YJzXw2Mupyx2IpWrevSHHYa1bi8t5qt/Vji9u ULI7vRqzM/M+Tv+BIDZkTDxcY1UYoWVwcLbdwsdw/GAqSseZyIds3FreVQ/r4+b1Rdgy kn6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=54zhWvY2wVoS8DJjdyrocZPF+2/4Isg+VJgEApzMseg=; b=emhkND+NL7xNzX4zTyGCkjn1WGOXowr52vYyFIPUvRul0NjX84TnDrmeiL/dr/xmQ8 IrIlROTQT6A4SOIX/xkyC1hCMq8GYGpRcYRSvoO5OekJKXcDMjnFHkw3zGGPVj1G7XgG JMQCVb1kllKtw3kfAmY8pqZwkePwvqhv2y4+5gGSB1i1BVUcevhpEde6FQ5Ad8XjUVDh MzNJdGvc+ATLRmNvKF0qwN868GWb+BrWh77drk48KyEpOpKb7t6dTOPkdL6+kxZN6R3f P5UiilA+TUIwcUn4Bbk6/trIxSEjp89uxgy4QB+oFYqG0JDLXa1v2PTJ/HepPvXu9BbU m3QQ== X-Gm-Message-State: APjAAAWSyJfIHjcnhjup2k2r7aQBaZkftJuHk3AMkA1URjNiv6O5JHUm XNMC2imwhb15lZZpY0U0Kt88bQ== X-Google-Smtp-Source: APXvYqy3x59CRPAE6btLW2GjTr9ElybCrYkLzTC0CHHa3cMsttfLkg9SMS47hmeEdoyqpluItNWgKA== X-Received: by 2002:ae9:f012:: with SMTP id l18mr41680079qkg.291.1571256048767; Wed, 16 Oct 2019 13:00:48 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id c204sm13342030qkb.90.2019.10.16.13.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 13:00:48 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, bhsharma@redhat.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de Subject: [PATCH v7 07/25] arm64: hibernate: remove gotos as they are not needed Date: Wed, 16 Oct 2019 16:00:16 -0400 Message-Id: <20191016200034.1342308-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016200034.1342308-1-pasha.tatashin@soleen.com> References: <20191016200034.1342308-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191016_130050_065281_7B1CDFB0 X-CRM114-Status: GOOD ( 11.88 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:742 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Usually, gotos are used to handle cleanup after exception, but in case of create_safe_exec_page and swsusp_arch_resume there are no clean-ups. So, simply return the errors directly. Signed-off-by: Pavel Tatashin Reviewed-by: James Morse --- arch/arm64/kernel/hibernate.c | 49 ++++++++++++----------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index 34297716643f..83c41a2f8400 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -198,7 +198,6 @@ static int create_safe_exec_page(void *src_start, size_t length, unsigned long dst_addr, phys_addr_t *phys_dst_addr) { - int rc = 0; pgd_t *trans_pgd; pgd_t *pgdp; pud_t *pudp; @@ -206,47 +205,37 @@ static int create_safe_exec_page(void *src_start, size_t length, pte_t *ptep; unsigned long dst = get_safe_page(GFP_ATOMIC); - if (!dst) { - rc = -ENOMEM; - goto out; - } + if (!dst) + return -ENOMEM; memcpy((void *)dst, src_start, length); __flush_icache_range(dst, dst + length); trans_pgd = (void *)get_safe_page(GFP_ATOMIC); - if (!trans_pgd) { - rc = -ENOMEM; - goto out; - } + if (!trans_pgd) + return -ENOMEM; pgdp = pgd_offset_raw(trans_pgd, dst_addr); if (pgd_none(READ_ONCE(*pgdp))) { pudp = (void *)get_safe_page(GFP_ATOMIC); - if (!pudp) { - rc = -ENOMEM; - goto out; - } + if (!pudp) + return -ENOMEM; pgd_populate(&init_mm, pgdp, pudp); } pudp = pud_offset(pgdp, dst_addr); if (pud_none(READ_ONCE(*pudp))) { pmdp = (void *)get_safe_page(GFP_ATOMIC); - if (!pmdp) { - rc = -ENOMEM; - goto out; - } + if (!pmdp) + return -ENOMEM; pud_populate(&init_mm, pudp, pmdp); } pmdp = pmd_offset(pudp, dst_addr); if (pmd_none(READ_ONCE(*pmdp))) { ptep = (void *)get_safe_page(GFP_ATOMIC); - if (!ptep) { - rc = -ENOMEM; - goto out; - } + if (!ptep) + return -ENOMEM; pmd_populate_kernel(&init_mm, pmdp, ptep); } @@ -272,8 +261,7 @@ static int create_safe_exec_page(void *src_start, size_t length, *phys_dst_addr = virt_to_phys((void *)dst); -out: - return rc; + return 0; } #define dcache_clean_range(start, end) __flush_dcache_area(start, (end - start)) @@ -482,7 +470,7 @@ static int copy_page_tables(pgd_t *dst_pgdp, unsigned long start, */ int swsusp_arch_resume(void) { - int rc = 0; + int rc; void *zero_page; size_t exit_size; pgd_t *tmp_pg_dir; @@ -498,12 +486,11 @@ int swsusp_arch_resume(void) tmp_pg_dir = (pgd_t *)get_safe_page(GFP_ATOMIC); if (!tmp_pg_dir) { pr_err("Failed to allocate memory for temporary page tables.\n"); - rc = -ENOMEM; - goto out; + return -ENOMEM; } rc = copy_page_tables(tmp_pg_dir, PAGE_OFFSET, PAGE_END); if (rc) - goto out; + return rc; /* * We need a zero page that is zero before & after resume in order to @@ -512,8 +499,7 @@ int swsusp_arch_resume(void) zero_page = (void *)get_safe_page(GFP_ATOMIC); if (!zero_page) { pr_err("Failed to allocate zero page.\n"); - rc = -ENOMEM; - goto out; + return -ENOMEM; } /* @@ -531,7 +517,7 @@ int swsusp_arch_resume(void) &phys_hibernate_exit); if (rc) { pr_err("Failed to create safe executable page for hibernate_exit code.\n"); - goto out; + return rc; } /* @@ -558,8 +544,7 @@ int swsusp_arch_resume(void) resume_hdr.reenter_kernel, restore_pblist, resume_hdr.__hyp_stub_vectors, virt_to_phys(zero_page)); -out: - return rc; + return 0; } int hibernate_resume_nonboot_cpu_disable(void)