From patchwork Fri Nov 27 05:49:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Youling Tang X-Patchwork-Id: 333851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F640C2D0E4 for ; Fri, 27 Nov 2020 05:50:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A268C221F1 for ; Fri, 27 Nov 2020 05:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392503AbgK0FuH (ORCPT ); Fri, 27 Nov 2020 00:50:07 -0500 Received: from mail.loongson.cn ([114.242.206.163]:45814 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389456AbgK0FuH (ORCPT ); Fri, 27 Nov 2020 00:50:07 -0500 Received: from bogon.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Ax6tCDk8BfNVkXAA--.44638S2; Fri, 27 Nov 2020 13:49:56 +0800 (CST) From: Youling Tang To: Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] tools: selftests: Add missing munmap() in check_error_paths() Date: Fri, 27 Nov 2020 13:49:55 +0800 Message-Id: <1606456195-23965-1-git-send-email-tangyouling@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: A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o: 5wdqw5prxox03j6o00pqjv00gofq/ Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add the missing munmap(addr_ro, PAGE_SIZE) before return. Signed-off-by: Youling Tang --- tools/testing/selftests/ptrace/peeksiginfo.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/ptrace/peeksiginfo.c b/tools/testing/selftests/ptrace/peeksiginfo.c index 5490065..3d64be4 100644 --- a/tools/testing/selftests/ptrace/peeksiginfo.c +++ b/tools/testing/selftests/ptrace/peeksiginfo.c @@ -62,7 +62,7 @@ static int check_error_paths(pid_t child) MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); if (addr_ro == MAP_FAILED) { err("mmap() failed: %m\n"); - goto out; + goto out_rw; } arg.nr = SIGNR; @@ -75,7 +75,7 @@ static int check_error_paths(pid_t child) err("sys_ptrace() returns %d (expected -1)," " errno %d (expected %d): %m\n", ret, errno, EINVAL); - goto out; + goto out_ro; } arg.flags = 0; @@ -84,7 +84,7 @@ static int check_error_paths(pid_t child) addr_ro - sizeof(siginfo_t) * 2); if (ret != 2) { err("sys_ptrace() returns %d (expected 2): %m\n", ret); - goto out; + goto out_ro; } /* Read-only buffer */ @@ -93,11 +93,13 @@ static int check_error_paths(pid_t child) err("sys_ptrace() returns %d (expected -1)," " errno %d (expected %d): %m\n", ret, errno, EFAULT); - goto out; + goto out_ro; } exit_code = 0; -out: +out_ro: + munmap(addr_ro, PAGE_SIZE); +out_rw: munmap(addr_rw, 2 * PAGE_SIZE); return exit_code; }