From patchwork Fri Jan 5 20:24:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JP Kobryn X-Patchwork-Id: 13512536 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07639C3DA6E for ; Fri, 5 Jan 2024 20:24:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 572BB6B02D0; Fri, 5 Jan 2024 15:24:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 521996B02D2; Fri, 5 Jan 2024 15:24:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EA566B02D6; Fri, 5 Jan 2024 15:24:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2A18A6B02D0 for ; Fri, 5 Jan 2024 15:24:15 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F27F2401EB for ; Fri, 5 Jan 2024 20:24:14 +0000 (UTC) X-FDA: 81646384428.30.68D9722 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf01.hostedemail.com (Postfix) with ESMTP id 51BA34001F for ; Fri, 5 Jan 2024 20:24:13 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Vgwdjzt8; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704486253; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=gQICQoKgAphHxDZIs5q9fKQEHP8PaxdXsRZTp7uR0kg=; b=PJ+ji3BvBTlSX7rR6xsQHafnbKNPgrMzRNc7YD0rs3hUgjn7LbKympaTHgy82ABW9ykB73 2XmFVD7S2G4VTG3DIf9gUhATdvWKMiWtJ38tOQA0pJDBH/VF1H+GqrumyZKONFv/d7VrgE hTsfUWHzxB0/iomI0qH+6uXwKxnBoAw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Vgwdjzt8; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704486253; a=rsa-sha256; cv=none; b=C9G5TryxC2lR+bNZ9Sg/gAE9vo3+X4EWcYP/JxkQS9YvYfUvGlBq8fEQhTx1hYZ3pyrl76 dKPa/pjtxI2pdt2LxVa9USm1zAVOrhSP9Hrbl9FCD2mDvpow8eT2nXeZxsNX7ceRy6/vcB 9kp/uA8CB85YkQzTEV6TiRJ3ZkT8mHU= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6da6b0eb2d4so1284033b3a.1 for ; Fri, 05 Jan 2024 12:24:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704486252; x=1705091052; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=gQICQoKgAphHxDZIs5q9fKQEHP8PaxdXsRZTp7uR0kg=; b=Vgwdjzt8tJRy+zsEn7LCzV9ykSl2bcD0I5/n2VkQIjB36sDZDJL+gwV+M4z6aOIiiq upWQpmaYqLkJcntmzBc6pfIedfH5klGWDowQqudXXQn5JH3QtOQTWDxUua34gOfYbZVA f2OSWmyyyJcFRKg1Y81vmMFJN2z24kSohbI/eMhDM20GIi06rYA/A8sL1/gGPc5b6mbE lHnX1Z5s3PmgnPgRGwhuT9I3Rz+GflGxQnjeeRY/quxB2KojQy3rNACTzra6N9kYREfF wPWjSXWDcrHLxddMznHxOYcearGGakBkHQkJJeksw3eivzhLtzcTDBkUDQMrfvuo77BJ 7WpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704486252; x=1705091052; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gQICQoKgAphHxDZIs5q9fKQEHP8PaxdXsRZTp7uR0kg=; b=a3GmUo1nMYML9ubowRofp8OD1v/J7rgAMXuEQmkDb+D5GKc0euXYM/JeGJJSsWAGGV BaIvgmpaPnqiEcQDWED84Dm2Q8mlr/gm1dHsn6KEAYnil3Y/XbsiVolC3e93QNIT/guV TF+j/bvPLn2FI3mJj8/a4USKlu/qToPd7JHT6yQaFJsi4YbTtWHXdQD5U7bWdqWIE4g+ dHUm/l+lXlTxvuONFLEHIBjvabObYfZ8tX5D3bvd/lGhr73yJ7Kl0YN5XEyslTtmEYcV tqDUA6j3zyUDfRkk1Y3dUfcIgzMHm3v+TCfhqk8QeFzJcC2mLXog760Y3Wkjty6Ma35y necA== X-Gm-Message-State: AOJu0YxdSyVAsitQr2oa7j+31wnYM2d2ZUM0+dFMiTJjhTYwTGtw0ZCj Pbjn9j15sqIGVwIZPeQ2NdYZQ5sm2EM= X-Google-Smtp-Source: AGHT+IFQJmnCH/qiSn6cYfFR3u27a9Tg4TTM75NRW+RtJp6bYfMULRp6X6ox3cysVUgXuR5OoQw6Vg== X-Received: by 2002:a05:6a20:9154:b0:199:5a20:9bf5 with SMTP id x20-20020a056a20915400b001995a209bf5mr633636pzc.83.1704486251599; Fri, 05 Jan 2024 12:24:11 -0800 (PST) Received: from localhost.lan ([2601:648:8900:1ba9:692:26ff:fed8:afdd]) by smtp.gmail.com with ESMTPSA id gx25-20020a056a001e1900b006d9be753ac7sm1799391pfb.108.2024.01.05.12.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 12:24:11 -0800 (PST) From: JP Kobryn To: linux-mm@kvack.org, david@redhat.com, akpm@linux-foundation.org Subject: [PATCH] selftests/mm/ksm_functional: prevent unmapping undefined address Date: Fri, 5 Jan 2024 12:24:01 -0800 Message-ID: <20240105202401.28851-1-inwardvessel@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 51BA34001F X-Stat-Signature: iphgzw4hkwqe91gf8doe9pyftm564u7c X-HE-Tag: 1704486253-673169 X-HE-Meta: U2FsdGVkX1/5gmtH0AQ4emO3QvKLCEzVjeXYwyX8quid0ULjUuEOnMe+Zd0gULRnp3O+CwWVFKQ0yx1jzRcwtMZYrdyEYTg97rUF230sYcb9SQ99SXRoBJgf/bulqBBHE3pfHkKdO1YmRWplla+v6NZlFAuF5PJuN2iM7yz7YCEqzyD/DJrVpSZnAqs4gExnf5DqM32uvoAwFLIQQncZoz+fZkFdqsbQl6HcbOsOR3DX6OiFHwpND23UDDbWRy9jxTi1qD0vHOxO7DDswnGguFoWtGI6VLXp2Ux79mMCfPHRVPMlhGAsooUmmFnAOVMxYZpK+EbP5oPhhcQHJ3Z/8KDoxmRSr9ht6zCAwzNI6iL2U3FpLtTbMAyXwppjp952G+6yLIRohjQujOHLPp0qbzot1wVCShKfh7B7JUugTV7MlclYqv7cw92PMjI89jBMSDqR3Lwgu2QBjm+WpmYwQ1iyhPXnCgeGX73E/xGJQUmf1EzOvecTenkMU4IxnLAhJtMIRbb4i9/vITF1wkIwsvwZbACKSsuNjhtnsc/uJyI+wCdOpxOLTZplCL6B3TaqMn1d9om3emuKvMkn+VVSfpgIZfHCIU2fmdsp36oDS4xGuv6rD+8+j6RTtDPdO3aZDKqWLEZGQiz31qmV//D/Pe0E6tUMRCCdV6T7/aohFWS4B6mpEu/c6gpmkrK4jyAaAR8aRFXQXdgLF/mUcRy9TOWkhI+cU0UdETKv7m/wgiYJLPfspHV/j5yrQ4wk/9rA/8nqL9NMQQOfySHjpMO2LbX0aWcditd+FLjhyTWFkswkUtfgrK9ZdWJsTDUDbTh5o8fH3FoI9Iwx6RF6lBVHhUSz5tHs0Bycb07bz/NHih7zwc3yhyYq50axm9sh9taQ7+WsxT/IgCOE74hWJOmLSRDEwpHPr7nsQkRW+22TFwdUSTN1NTAgRaoIDVQK+dZkW/3AR/glawhwsAVQuAr 7khViZ5t bzaDtkCxO/5OV0QVrl771A1KFRrEwMysyEHzsyLobYota9dpx5U0dtfjrA+XJiDHoasPjdFnDI8ZmJtD/LoVLWj0BWwCaefuhDaypjC3UUNloZTMGNyQo3Sh3kQaFiGpk3kU0hKsMd670Yqcg5BgM67FNSD08s6uNh5/WQA1VC+CX2P5fXW6cjGAMv9TvXLVS7tBGFNoGTmnko4LHAA++y3HT95sIZd5AgQlIOht91OH9561TE64V4uO4lRgxy0fCjMKGK1tABb72alWeqmsSR6K9qLsGVQFMBdISHKAgW2QFrI6uDjHJVDdcfMiZn52oJNeKHkmJd2ttAbBB8Vqz2eoH0LX8cBF0t1Pv7fmEpIei1UNdKqV0Jl+sNyujjRxYhte2NZuuX62guQEUHWmkMhxbu7Y+I9ZgsLwo07H+XvAFtNe7jfHSKuT7Ho0+Keonm5Q/lqzgFaVTfyugwpldf+3/TumxRlxjag4PdUNYggePJQTN5sJmgvSr2Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000422, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Replace some goto statements with return statements so that unmap() is not called on an undefined address. This change is made so that unmap() can only be reached after mmap() is called (and the address mentioned is defined). Returning MAP_FAILED seems acceptable since client code checks for this value. Fixes: 42096aa24b82 ("selftest/mm: ksm_functional_tests: test in mmap_and_merge_range() if anything got merged") Signed-off-by: JP Kobryn Reviewed-by: David Hildenbrand --- tools/testing/selftests/mm/ksm_functional_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c index fbff0dd09191..d615767e396b 100644 --- a/tools/testing/selftests/mm/ksm_functional_tests.c +++ b/tools/testing/selftests/mm/ksm_functional_tests.c @@ -155,12 +155,12 @@ static char *mmap_and_merge_range(char val, unsigned long size, int prot, /* Stabilize accounting by disabling KSM completely. */ if (ksm_unmerge()) { ksft_test_result_fail("Disabling (unmerging) KSM failed\n"); - goto unmap; + return MAP_FAILED; } if (get_my_merging_pages() > 0) { ksft_test_result_fail("Still pages merged\n"); - goto unmap; + return MAP_FAILED; } map = mmap(NULL, size, PROT_READ|PROT_WRITE,