From patchwork Sun Jan 21 00:20:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 764462 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp530284wrx; Sat, 20 Jan 2024 16:22:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw1/S77RYdaK5v9jNRzd8jBcKQSA8MNhBRS837eQUSMff/8+ZZBrgiU4A8Ral4yH1n/6X6 X-Received: by 2002:a05:622a:40e:b0:429:caf9:f3af with SMTP id n14-20020a05622a040e00b00429caf9f3afmr2685753qtx.137.1705796539223; Sat, 20 Jan 2024 16:22:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705796539; cv=none; d=google.com; s=arc-20160816; b=NrjZh4Clahpr+WDNFvDoRZeG8FXNSXtlZ6NhcFqWwWMErfU8J7XU95PPXifhXlEht+ wTVwhnhpfl9ZQlPDiVpGLS0wCdjnacQFBBRvBAbHE7yVW3tXeLA/ekfiG+KCqrmFP0we yV2ABc9yZH5TXRTmJS3BumDUyMb9H1X8cF2D7IvhYEpmQy5Vrr/UrZzkvy2IQEwOlEdC 4R5K2Lsoz44S5kYVJdzID5yFOmhdIAygQyhaiWq6WlgPQOQyyN+BO7/IcoGNEGJz3K9o 1S5u8W7iPSFTS4LQJhJKtLYSZ0wePlBHFAQl4IxGe3KcH95HLM5itdxo0wa/SSP0p/FN yeEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0EKsORzhcd/voY/5GCXD+0ZH5a0YI/B7BiYyHrdge+w=; fh=Po6svqgyYqJzxZwR3KQKdPHXCr391FTx5wiDQXhlWnU=; b=SdsSmscUC6sHqZnfRz2vVuEiotA5PTSBC4MnLnHdodjK8LPPVbdV0yRrR8n2I2TZ/L p0oufPbROFwy9Vljton9DtRH9yZrdimDfl6BMe0dmIRfwYKMCu56p27hLbC5EhOeJsGy +SNmoKzd8flb+yuyc12smasjvShKNpD40XQVX+4W5gfeDoWcCA3FCUrDhVk0mBjKF9JT KiDEvBy3J4YiUjwDzIVQ7bdkE/bsTQM/pEiypcQAFT29GpS6/89zeiP5oRMGpty7oZ67 t30c190TEzhjVWZ4YGEGn0me6ldOBz1d/Xdfe2YbQSSbwa4K0yxRWO2AnIsqYbLWwnvp +NpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nqalHe+r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k14-20020a05622a03ce00b0042a26a6d43esi2525296qtx.101.2024.01.20.16.22.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Jan 2024 16:22:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nqalHe+r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRLaB-0002Vl-E7; Sat, 20 Jan 2024 19:21:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRLaA-0002VV-8l for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:02 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLa8-0007NJ-Ll for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:02 -0500 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2907a17fa34so321870a91.1 for ; Sat, 20 Jan 2024 16:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796459; x=1706401259; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0EKsORzhcd/voY/5GCXD+0ZH5a0YI/B7BiYyHrdge+w=; b=nqalHe+rh82CZBZ1Z/S67KA8JIcjQHp7CLdyJwb1G8HPF6tCcI1DF+Hnv2uyRe8gNu q7ggjET41HzG9uutAQKUzdacn9s9CMBTOf4NBXdbe5mv8m5uSC0m+u9JVBDf8WWkdqa+ zYV6+fFJoQancPRxF50YJjWHBjD+4ev1Zk5KuhS0xxTJsYbn/VBpfV53DTYOHoltzBBK vJbVmBR3f8UOHj8vujYo6YbL77yG7mldXfCMa8JDDMzmcfw5VIf77KTAfr6Vcf/XZtR8 7Te/gFg+bTdjp5i9tcti2qgrdVT5RblfsfMvdo/OqoXsRWHQwPaDKxqhxNOshaGgvHS9 Gp5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796459; x=1706401259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0EKsORzhcd/voY/5GCXD+0ZH5a0YI/B7BiYyHrdge+w=; b=wriyRuX0FdbwcvFLiL4zV1IYrFVys44JzojlCpzcg2F2jLy6vdct4pYGjlpJfsrqzu btfh/udgvYsj/xRyV7A6PcCAh3OZXPJ1Oqe9BuTnQH2ZgPzk7f/EIqdhNHqpPzsy853C 6Cy/PeosrPLN+nlC8VxtZmVwI2bqaMxjf++Q2847Fi+6ImRHjEpz20JtuAPkTO7yOrTW 3n2PQzrcXe8xoqVVwVJ576/Dv14daLLYKUwJuHAtn3MGV/iq58DcKdooKIBK4QokcmfG wQhEpHnsUIg+8/yMocYfNqoH9kGLphPv/VkrOLGrgHOff5WDOpQfZtfoYbouQ6Fm5x0s jVog== X-Gm-Message-State: AOJu0Yw7GapxQbnG9IL5bVA8tXMWQu+sbCVkZA9TitwNv0yUK77EOxvG uqY3HjA2zz9aFakXvzPiJ6dUVgC8dbEPVfebyDmRUMsWU51IGo4oYi3BK6xBmLG56qHfxHDlwGY CwKI= X-Received: by 2002:a17:902:7601:b0:1d7:4821:b567 with SMTP id k1-20020a170902760100b001d74821b567mr151074pll.139.1705796459447; Sat, 20 Jan 2024 16:20:59 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:20:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Samuel Tardieu , Peter Maydell Subject: [PULL 2/8] tcg: Make the cleanup-on-error path unique Date: Sun, 21 Jan 2024 11:20:41 +1100 Message-Id: <20240121002047.89234-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Samuel Tardieu By calling `error_setg_errno()` before jumping to the cleanup-on-error path at the `fail` label, the cleanup path is clearer. Signed-off-by: Samuel Tardieu Reviewed-by: Peter Maydell Message-Id: <20231219182212.455952-3-sam@rfc1149.net> Signed-off-by: Richard Henderson --- tcg/region.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/region.c b/tcg/region.c index 467e51cf6f..478ec051c4 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -584,7 +584,9 @@ static int alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) buf_rx = mmap(NULL, size, host_prot_read_exec(), MAP_SHARED, fd, 0); if (buf_rx == MAP_FAILED) { - goto fail_rx; + error_setg_errno(errp, errno, + "failed to map shared memory for execute"); + goto fail; } close(fd); @@ -594,8 +596,6 @@ static int alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) return PROT_READ | PROT_WRITE; - fail_rx: - error_setg_errno(errp, errno, "failed to map shared memory for execute"); fail: /* buf_rx is always equal to MAP_FAILED here and does not require cleanup */ if (buf_rw) {