From patchwork Mon Sep 9 18:12:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11138335 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 B603014ED for ; Mon, 9 Sep 2019 18:12:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 801EA222BF for ; Mon, 9 Sep 2019 18:12:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="UthcQ8kO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 801EA222BF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 38CA86B000C; Mon, 9 Sep 2019 14:12:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2052C6B000D; Mon, 9 Sep 2019 14:12:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0097E6B000E; Mon, 9 Sep 2019 14:12:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id CF9006B000C for ; Mon, 9 Sep 2019 14:12:32 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 5184545C1 for ; Mon, 9 Sep 2019 18:12:32 +0000 (UTC) X-FDA: 75916177344.16.boy71_6d67a4ddbcf3f X-Spam-Summary: 2,0,0,d504dfbc86306273,d41d8cd98f00b204,pasha.tatashin@soleen.com,: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::mark.rutland@arm.com,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1381:1437:1515:1535:1542:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3870:5007:6117:6119:6261:6653:6737:7875:7903:10004:11026:11658:11914:12043:12048:12114:12297:12438:12517:12519:12555:12683:12895:13894:14096:14110:14181:14394:14721:21080:21121:21444:21451:21627:30054,0,RBL:209.85.160.193:@soleen.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:no t bulk,S X-HE-Tag: boy71_6d67a4ddbcf3f X-Filterd-Recvd-Size: 5666 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Sep 2019 18:12:31 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id c9so17255985qth.9 for ; Mon, 09 Sep 2019 11:12:31 -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=Zyn9vu/MXqap+nTmKUuDMqr9t65lKRkBEWPsGRxQJWw=; b=UthcQ8kO9S9FCLunJhnz0p5vTTeqpswrs8HKI3djcyn4qVoYH5c1zslsQ8icQsNuPw lTHINs8zJxAuS3r7gWwVequPv79z7btg4C4cIvo/Bvv7pMUfe3fuVe+bUmep95QO26L2 BI+gHcf2ROIyYWP16vdZ+yqFXHBvGWqGqai0v9yIfE//FjF2txzR9RwNq/Ro6no5KKwV SKLynI2BWiFTWDKzVEX3Ev6oQFBlSmwcv6iEYGjrpwCBHaXU8FBvmaYyobFXAihr09Sg +JDVKpR/sFM89wtVQck3jZCL1jiTauTsbPzPg+yIyOU05PD6RocOP6Ax0DRQKCCIMsDE CEUA== 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=Zyn9vu/MXqap+nTmKUuDMqr9t65lKRkBEWPsGRxQJWw=; b=VjCc/3o2osWc1LJ5WrRK+GPu8iiH+498KaGnr9OuLw2ntEcx+yfNzZUUBXK4xX4q+h wViSLL37vPcZAzxFIFFlUAyucANhMacx3yFNqJRdumo63I6ijBCH7JATEdXCSaLeEiEk ImyOfNi1/3mLuixBS/CXm90q47DtJw1mrJ3iejUDKKqNdXDClI1zWnCUMc0efEWsw+ie 25HkgZ62oYpkVbL8UbQaZwRXwtTlhVyH2YZ+L8wFLj10gYMnNWGH8PhAnmKpvD5FJl5N 3N2pZsUXZT7WWrRg4wrqMuMtCX4o4HlkT/VwjyV1Fba5m0XEz5oMSdHME+NW9dy2s0bE GgKA== X-Gm-Message-State: APjAAAXbYm7VwseTOVMWwRgseGAC0mBB+8z/IffQ/qPBKH0UtIcctVbm O57eH5MJMyX6xruLl7mu6fh/HQ== X-Google-Smtp-Source: APXvYqxD+/dgh77RiunjjHz4vq1SlUkRHl7ZhEwgGQCd/ojd17d3Y9qj1SZatp7epiPygaYzVXaPxA== X-Received: by 2002:a05:6214:451:: with SMTP id cc17mr15008123qvb.15.1568052751174; Mon, 09 Sep 2019 11:12:31 -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 q8sm5611310qtj.76.2019.09.09.11.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 11:12:30 -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 Subject: [PATCH v4 05/17] arm64: hibernate: remove gotos in create_safe_exec_page Date: Mon, 9 Sep 2019 14:12:09 -0400 Message-Id: <20190909181221.309510-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190909181221.309510-1-pasha.tatashin@soleen.com> References: <20190909181221.309510-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Usually, gotos are used to handle cleanup after exception, but in case of create_safe_exec_page 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 | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index 47a861e0cb0c..7bbeb33c700d 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))