From patchwork Tue Jun 26 17:14:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10489785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D89560386 for ; Tue, 26 Jun 2018 17:15:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00C9C27F9F for ; Tue, 26 Jun 2018 17:15:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E95DA28779; Tue, 26 Jun 2018 17:15:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA00627F9F for ; Tue, 26 Jun 2018 17:15:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753089AbeFZRPJ (ORCPT ); Tue, 26 Jun 2018 13:15:09 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:37936 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753063AbeFZRPF (ORCPT ); Tue, 26 Jun 2018 13:15:05 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5QHBd1u021109; Tue, 26 Jun 2018 10:15:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=aI4gXxQ6MbQeSftho6gWPOh6MvkPbNrPAcwcNkf1+MY=; b=DtLoe+rvsf3l91X13eVN5c4C6PYf0RRf2ILqrmn0IqeKtL0O2zTE9y+HIthHVMXXp+cW cLjBBQTU4aY6sN8IM+aVbUw8hnuJSqunUQTsPcE/Qy3SyEsrH07bkWrE18UG0j/8Q2C5 HGcqyNFu9orYmwohrFtBGC36xuPTmlzyVz0= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2jupxrgjnm-3 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 26 Jun 2018 10:15:02 -0700 Received: from NAM05-DM3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.30) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 26 Jun 2018 13:15:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aI4gXxQ6MbQeSftho6gWPOh6MvkPbNrPAcwcNkf1+MY=; b=geAHCSTuzhvAwZyOfGFGLdvdhMuUEbiPDvsemGZqyd6FRzZs0noLQkl4HtcRB4xcGseBUlVYerHNSB4dpS/oySEhn19u3duudXkcMwykoXusiEDgPRvnf7uYPbAswwA3cV80xBC93pZ2YKDLj/rE2NGAiy+S9BJr/d1KtsEM29I= Received: from castle.thefacebook.com (2620:10d:c090:200::6:5da8) by CO1PR15MB1078.namprd15.prod.outlook.com (2a01:111:e400:7b66::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.20; Tue, 26 Jun 2018 17:14:57 +0000 From: Roman Gushchin To: CC: Roman Gushchin , Shuah Khan , Mike Rapoport Subject: [PATCH] selftests: cgroup: fix cleanup path in test_memcg_subtree_control() Date: Tue, 26 Jun 2018 10:14:10 -0700 Message-ID: <20180626171410.10303-1-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180626090347.cuwod4fv5koqbu63@kili.mountain> References: <20180626090347.cuwod4fv5koqbu63@kili.mountain> MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::6:5da8] X-ClientProxiedBy: MWHPR03CA0025.namprd03.prod.outlook.com (2603:10b6:301:3b::14) To CO1PR15MB1078.namprd15.prod.outlook.com (2a01:111:e400:7b66::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4447cb08-5613-4556-0db0-08d5db885810 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:CO1PR15MB1078; X-Microsoft-Exchange-Diagnostics: 1; CO1PR15MB1078; 3:2O1XXJBQ/ISEU5fJ3VLsCehfzZMFPyYgz6S9xO4Y9ISJ0fhCKn/fFcbeKOjNEtAr7K78utYirSq7Px0F/YUQdECIeoti3Y4boNKI/VVButLxzQmPePc2p2mNDGFGJ5MFst7jSHm0fVuIAvE6U5sYt9nDC9/UP1HblaHICAytHTuPkHPHkZ/3EHnmJEzeIaDIJ6Ss3PzOibI0cLbMFpxXgrEI9ufbaJjJUJhAE7RJtY05WosgDCwLIeEqrVnL3NHh; 25:GHbJN9psJiQNfzoNDH9UFu7U6zw8HnF71URl2QPmENakDTXSFaFvl0oXl9e4ubUpw0OARKC9HqznmElTFtaO8Eadj+wieU0u7q09iNnpyp0Wl8u7TwUpG1o96RygkaDL6HbfMjK+FTYITULvxuMuTxiZbSJ4RAFmk97ehL1u30G8exBGfka+k5KWWoSxjEr79HSVTQ4B1QIWYPYALOjNb2jN0lar1eNZGg18K7ds/kC/ha4wQxNzczwdIzn48EkVCjdct1gm0N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4/KplZ/PpqRYNoJOkPmz2F+D4cfJ32hWQu1tdLhlQ+GwVRZiaAD+g8ahxaIycZXN8HxDhcSiNE4Jl+iKJ1/I5k+gNwhd8C/bo36sLE3xhtdGvdMltMuMlaiSYfDkXLY8vOyTI0nYo8ZMkOyBS/lNOy7chvgM4kL5uOF/LQktKD8x0XzCSf6TtpaU11dTYjuPJRkqe5v X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484)(104084551191319)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231254)(11241501184)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:CO1PR15MB1078; BCL:0; PCL:0; RULEID:; SRVR:CO1PR15MB1078; X-Forefront-PRVS: 071518EF63 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(376002)(396003)(366004)(346002)(39860400002)(136003)(199004)(189003)(16586007)(316002)(305945005)(54906003)(7736002)(16526019)(6916009)(186003)(1857600001)(69596002)(2361001)(6666003)(5660300001)(6506007)(52396003)(6512007)(6486002)(52116002)(51416003)(76176011)(36756003)(2906002)(486006)(11346002)(446003)(46003)(2616005)(386003)(476003)(2351001)(105586002)(47776003)(25786009)(106356001)(50226002)(68736007)(53416004)(14444005)(48376002)(50466002)(1076002)(6116002)(478600001)(8676002)(81156014)(8936002)(81166006)(97736004)(575784001)(53936002)(4326008)(86362001)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:CO1PR15MB1078; H:castle.thefacebook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us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FtjjEfHSTwlkw81jLNxuteTVEHmNqgYV3?= =?us-ascii?Q?CMs7VbY3jhPftKwh3uD6DixEkfgh97Pt6iIITFkNqAIem9W9bZddn+WQNK8z?= =?us-ascii?Q?zdgjB+BuduSPF16MUVbcmPv+MMkDmFqJp+T42NHR8vMJDU6umhUc+K0xs0iM?= =?us-ascii?Q?1QxXRLigaed//U0gL7kGBQ1UdG+xXbPA9bGGs83dMBwEEgsQbGzAgsk19VbR?= =?us-ascii?Q?BbKL06abGsxK85RElEEMt99k5ykbNRC9q+tjNmfDPsgmbzL6NPu+erjcQCxK?= =?us-ascii?Q?MERHx23dNXoRRai1sGQTH/o0nbT4pxPYjZZ95bfMNZYA1iqTNrZs4Mxxd5ep?= =?us-ascii?Q?S5JpwQkUsxwZxSCp81AwBGjfkc69jKBe5Swrxs2vF3mCRuVGG+JLipVrFPDR?= =?us-ascii?Q?5VoziC7MePw96vatbw659wEk5pB+Uai9poFPCKjTRKFt/ZIG0iGM2XGquAFX?= =?us-ascii?Q?2KaAuzvHV5xEKx3It3ySNqb+ZzccP6p6dboBHXFHlXn?= X-Microsoft-Antispam-Message-Info: 1fQJHOqoH9yazx7EIkg9ErtDNqY4fhXPPUUAFS9KrnZ+D7R9UPcqTFv3eWOaIBtXD5agsqQlzbHftSIkC+2s5m4LoSLqArFhGYaMR5i9Ver8xmd+dGQB3gs4elyloPnJ4j/hDUojKeBoJ6dTCDmsdEKPisztsw6tSjchGK8vAT0XhwTdpq/t80htMjm8nlK3Fz97Ybz9SPkC8czdRXfSoy5bWpx251lsags1r8PazTF2a4gaEzZnIpl27bPD2j31/XzglsCW5+ZMEDbdKEsC/N4jipTx2dRUul97NqnBOrDfn7I1PMW94NdpmJC/PG4Dw49Aq1ftN3xckbD7zwXgGrElmyUKhF9g7gbbweAzIgw= X-Microsoft-Exchange-Diagnostics: 1; CO1PR15MB1078; 6:eOjmhOEFQpyVnyzPbJiGjfl4XG6Z5QGxaCHYpSZfsPrj1NjMxBCfIaxc54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5IYBNXGAd8cOcNKS7ybFvgkk0dP43VmKs8XCQG8OVLgp198BSdBuRt7HMSVPoqaPJ7Qll/3V83GxixYv9dPkrPgWo45EShdLZhO7yu1SJCNugm3+hxe9b/iocyw6jORKOVtc= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2018 17:14:57.8942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4447cb08-5613-4556-0db0-08d5db885810 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR15MB1078 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-26_09:, , signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dan reported, that clenaup path in test_memcg_subtree_control() triggers a static checker warning: ./tools/testing/selftests/cgroup/test_memcontrol.c:76 \ test_memcg_subtree_control() error: uninitialized symbol 'child2'. Fix this by initializing child2 and parent2 variables and split the cleanup path into few stages. Signed-off-by: Roman Gushchin Fixes: 84092dbcf901 ("selftests: cgroup: add memory controller self-tests") Reported-by: Dan Carpenter Cc: Shuah Khan (Samsung OSG) Cc: Mike Rapoport --- tools/testing/selftests/cgroup/test_memcontrol.c | 38 +++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index cf0bddc9d271..ae8f04f84b03 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -25,7 +25,7 @@ */ static int test_memcg_subtree_control(const char *root) { - char *parent, *child, *parent2, *child2; + char *parent, *child, *parent2 = NULL, *child2 = NULL; int ret = KSFT_FAIL; char buf[PAGE_SIZE]; @@ -33,50 +33,54 @@ static int test_memcg_subtree_control(const char *root) parent = cg_name(root, "memcg_test_0"); child = cg_name(root, "memcg_test_0/memcg_test_1"); if (!parent || !child) - goto cleanup; + goto cleanup_free; if (cg_create(parent)) - goto cleanup; + goto cleanup_free; if (cg_write(parent, "cgroup.subtree_control", "+memory")) - goto cleanup; + goto cleanup_parent; if (cg_create(child)) - goto cleanup; + goto cleanup_parent; if (cg_read_strstr(child, "cgroup.controllers", "memory")) - goto cleanup; + goto cleanup_child; /* Create two nested cgroups without enabling memory controller */ parent2 = cg_name(root, "memcg_test_1"); child2 = cg_name(root, "memcg_test_1/memcg_test_1"); if (!parent2 || !child2) - goto cleanup; + goto cleanup_free2; if (cg_create(parent2)) - goto cleanup; + goto cleanup_free2; if (cg_create(child2)) - goto cleanup; + goto cleanup_parent2; if (cg_read(child2, "cgroup.controllers", buf, sizeof(buf))) - goto cleanup; + goto cleanup_all; if (!cg_read_strstr(child2, "cgroup.controllers", "memory")) - goto cleanup; + goto cleanup_all; ret = KSFT_PASS; -cleanup: - cg_destroy(child); - cg_destroy(parent); - free(parent); - free(child); - +cleanup_all: cg_destroy(child2); +cleanup_parent2: cg_destroy(parent2); +cleanup_free2: free(parent2); free(child2); +cleanup_child: + cg_destroy(child); +cleanup_parent: + cg_destroy(parent); +cleanup_free: + free(parent); + free(child); return ret; }