From patchwork Sat Mar 25 18:30:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13187841 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 33A51C6FD1C for ; Sat, 25 Mar 2023 18:30:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D4A26B0072; Sat, 25 Mar 2023 14:30:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5846D6B0074; Sat, 25 Mar 2023 14:30:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 475826B0075; Sat, 25 Mar 2023 14:30:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 38E456B0072 for ; Sat, 25 Mar 2023 14:30:53 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E7223C0115 for ; Sat, 25 Mar 2023 18:30:52 +0000 (UTC) X-FDA: 80608261944.18.ADF87CE Received: from mout.web.de (mout.web.de [212.227.15.3]) by imf26.hostedemail.com (Postfix) with ESMTP id C4952140005 for ; Sat, 25 Mar 2023 18:30:50 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=web.de header.s=s29768273 header.b=E2ZRLGzB; spf=pass (imf26.hostedemail.com: domain of Markus.Elfring@web.de designates 212.227.15.3 as permitted sender) smtp.mailfrom=Markus.Elfring@web.de; dmarc=pass (policy=none) header.from=web.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679769051; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gpd002g83eYHAwa8nXb4Tip7JW96SuuMFbMMvMgqptU=; b=ad+iyuZyS/R8SN55XMjc57RufNRFXv6w7uDk4Q56fVoO9r/ulJHO63DkCpBIyzrSfU+plp UxvykPa/hRzrP/ROCZPmgMNtOqM2AW30ik+GUJcVwJiQKVDyaMltkq6CL8boGYHnVyQQtA naepoBLcA8AoNHFA3hcsLgLUhUhWKl8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=web.de header.s=s29768273 header.b=E2ZRLGzB; spf=pass (imf26.hostedemail.com: domain of Markus.Elfring@web.de designates 212.227.15.3 as permitted sender) smtp.mailfrom=Markus.Elfring@web.de; dmarc=pass (policy=none) header.from=web.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679769051; a=rsa-sha256; cv=none; b=PmXkNo17Du4Z2lyz4tggfQGOpf92ERHuQn4+JMM4q23wyzYO5yNf7Z9l0nGq08z6PJu09/ FXK89nTg72P30wCmR/P5PHWwgTBCNwgzWnwacF3ZgrWsqPPiMoMatPR/9c+4pV5GOq4zM2 GGMEOyE/G7NvPJn76sU6yQk5fZED5C8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1679769024; i=markus.elfring@web.de; bh=v+rMXJgncvNeSS/c9GxyeVsaVJFxHUrosoDsvsBMKrA=; h=X-UI-Sender-Class:Date:Subject:From:To:References:Cc:In-Reply-To; b=E2ZRLGzBeWgDUjxxuDBQNzCqbzkObNJ2PQYpfhURJww+hylN8N/+Ouqj1TTy+BTOT KbbxOqGmhbMKUzW0DrODYY0DpSNyvjAlZo5JB5snAXMrqmjwUvC5O/X7HhGIVkJ7hx QfY8Tk4xJFvpdqiZY5oi+x6dAvscXBmijG2O7Qt4fFK4GByO5igabdQCDOLkDhsOhz iWbYW3fZ9qDZD4KyS6I4pNxcfbrHVMG7qc6dPYdFlyUwKOU8F2VdV4dTE73RPtWyRM 8nAXhcDQKG/uA4ki9G6xPVxRcr/1646dFRU/l3HulUc7c8Hfeodny9CFUkdGi6AD7M 2CIyWbOgXof2A== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.83]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MYcpr-1q1KYe3KoV-00Vmpk; Sat, 25 Mar 2023 19:30:23 +0100 Message-ID: Date: Sat, 25 Mar 2023 19:30:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH] selftests: cgroup: Fix exception handling in test_memcg_oom_group_score_events() Content-Language: en-GB From: Markus Elfring To: kernel-janitors@vger.kernel.org, linux-kselftest@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Jay Kamat , Johannes Weiner , Michal Hocko , Muchun Song , Roman Gushchin , Shakeel Butt , Shuah Khan , Tejun Heo , Zefan Li References: Cc: cocci@inria.fr, LKML In-Reply-To: X-Provags-ID: V03:K1:h18z4dZIBJTIQ6TPT3oGEZ7o5iXlXWx0RTutB2xT+a1UQZRqGQk /qyP1bx/IKo89hqEhWz/HyfbUh/nbMI+1K0zvotD5zKnNg2nfAmTQXvZBxquxA0pNJ99dkZ g+DAk9fcs1EWE5piNmh7lbGxM7Y0tmnjGEkRnt4iPIwFs/e1AOYR2sBUDNt5W2bfEwFmV39 LqH84dG4X/a7AEXZEvJGQ== UI-OutboundReport: notjunk:1;M01:P0:s/wtJ8pkZg8=;g+PAu3mjM4Vpcsl0C8p621g6/6S evIunpd0Z9Attev8KCqn+lz2DtQspTGPM47nMOGjNNhqP8HOdomV6kwkt1QAHZcyEzdxEaGjv fMaxIzQXWUBReCFTrBU4dnrm/vdpyvM0hdTgReO+rFa0wfHkvvCJss1c5pB31ku3wo9BhKWyi ORp+sP2Pesd0hFKaIBFpf5M4JrqcrePePpD7cLXw7EKGfqxRenwX1c7hpZCFB7N9ownp0wGky ozyQN2xiDOgyEvSgPFSQ9WmB5k738wjzc6WO793OxwQaAMNQfBx134Ks3YZdxgTr3hbe2Zj8d Z4nOthoPMSSLboGX6RMbynrTka89+Y/P9yn1nZIEnWKCy0McHHz/1sBWT7X1n29hzcyhvP7FF xL2Kc9tJXfnlUkZtp5jEh03mAXvp11ziJvANMvPJ4U+2/oWa3nmz2fzi3PtVSbOIv3qrzMcDS m9ix5UgBpUB97k6A7whUGAicpzeQQas9w1T+SmFlkvmOt+jvB4ozjV65E5uEoOyvsTjnn+SLm BPDpT02oh4IysjrMGnnFvB8OY4Gs2qknJTCnRymqXHMLZJ7gg7OmJvIGe0PAtVfX62Bstbs9R u60KsZGuoVBU4xs5rY+Hg+cbUTvHyGvldsU4UW2m2/dY0XFxb8cPWLUocD40VFoatZVR/KONI y/T4C4j6FZRt2FAk2WCXaNvP+1mh5cHn8PUleC1ZU02DpMVvIixP0k+1IiWWGP6yesSiaMBQg XCjQOS8E084M1KUPQMiLew+26UzhtgMepZNhib7FtX1jp7cmkz351v1uDWPIF4XOffw3W011F ws2TGuNDkfk2LE3yHUbBm/5yZkibfqXhF6mPP9chIPueSQ6QU8+CPgq1BRc/U2lfI+wQ4kObA X5D6NoROwlBSBPHhqlz5pslEUWC9dzleFCWruf4BNXj/4U32KaATYGTiV X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C4952140005 X-Stat-Signature: 33qgyx363pukzf18hcsoreno5pahez7f X-Rspam-User: X-HE-Tag: 1679769050-606461 X-HE-Meta: U2FsdGVkX1+zZ0SuTUhCNjWEaD9mJm6UpiHzPLL43jG+w8ZAu9mzQtOVkZZWbbouSfnBTUQNj/J6kVPA3HVlqBUG7n6suGLn36LRehqnIwuOPgECIGP9qedCmjFLdQU4966V/lLd3W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PINrLeR1r6I0Y0N6G26XIMoqkwJg3aNsKPiN8YkIJofcatw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000030, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Date: Sat, 25 Mar 2023 19:11:13 +0100 The label “cleanup” was used to jump to another pointer check despite of the detail in the implementation of the function “test_memcg_oom_group_score_events” that it was determined already that a corresponding variable contained a null pointer. 1. Thus return directly after a call of the function “cg_name” failed. 2. Use an additional label. 3. Delete a questionable check. This issue was detected by using the Coccinelle software. Fixes: a987785dcd6c8ae2915460582aebd6481c81eb67 ("Add tests for memory.oom.group") Signed-off-by: Markus Elfring --- tools/testing/selftests/cgroup/test_memcontrol.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.40.0 diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index f4f7c0aef702..afcd1752413e 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -1242,12 +1242,11 @@ static int test_memcg_oom_group_score_events(const char *root) int safe_pid; memcg = cg_name(root, "memcg_test_0"); - if (!memcg) - goto cleanup; + return ret; if (cg_create(memcg)) - goto cleanup; + goto free_cg; if (cg_write(memcg, "memory.max", "50M")) goto cleanup; @@ -1275,8 +1274,8 @@ static int test_memcg_oom_group_score_events(const char *root) ret = KSFT_PASS; cleanup: - if (memcg) - cg_destroy(memcg); + cg_destroy(memcg); +free_cg: free(memcg); return ret;