From patchwork Tue Jun 26 17:22:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10489811 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 AF9D86023A for ; Tue, 26 Jun 2018 17:23:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 921DC2873A for ; Tue, 26 Jun 2018 17:23:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86FFC28751; Tue, 26 Jun 2018 17:23:03 +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 01BE72873A for ; Tue, 26 Jun 2018 17:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752630AbeFZRXC (ORCPT ); Tue, 26 Jun 2018 13:23:02 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:34392 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751171AbeFZRXB (ORCPT ); Tue, 26 Jun 2018 13:23:01 -0400 Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5QHI8aD021808; Tue, 26 Jun 2018 10:22:51 -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=jWRtz20L8IOpGoRqaNiv0HLD9a+G60XqAfuGbNGMyDQ=; b=d/zYJndV6I2vuHeUJRXGoq+4UEsDQ/OU19rhEQBg2KZ3F21+zKvkG82s/aCtuEW8D5b/ yPqAQuHByty5C53LDvOAi+oZ/F8jj06NCUHQz4ruKd/jqumkQlEesj+DICElsURywGvE yDKib5O4Xix0zlWw78td+K3Sr3FYnspOo0I= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2jurnf88bp-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 26 Jun 2018 10:22:51 -0700 Received: from NAM05-CO1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.31) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 26 Jun 2018 13:22:49 -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=jWRtz20L8IOpGoRqaNiv0HLD9a+G60XqAfuGbNGMyDQ=; b=LzaRhk9dnR0KobsUiaSZsVe69LSmRkkSqugBnlOYkyNVZSmd3Ui1rgygFaXZ7MXWCCASLhiB2qe/Y1E89H4TWFi3Lq4zYZ/D3MzaU1JiS9C4+R3miSsy7rhU7MPCJ6V88P2nbrcJyzdNGbjOrzTM/futkPMjAE762zwvJBh52dE= Received: from castle.thefacebook.com (2620:10d:c090:200::6:5da8) by CO1PR15MB1077.namprd15.prod.outlook.com (2a01:111:e400:7b66::7) 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:22:46 +0000 From: Roman Gushchin To: CC: Roman Gushchin , Dan Carpenter , Shuah Khan , Mike Rapoport Subject: [PATCH v2] selftests: cgroup: fix cleanup path in test_memcg_subtree_control() Date: Tue, 26 Jun 2018 10:22:28 -0700 Message-ID: <20180626172228.12590-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: MWHPR13CA0030.namprd13.prod.outlook.com (2603:10b6:300:95::16) To CO1PR15MB1077.namprd15.prod.outlook.com (2a01:111:e400:7b66::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 50039075-f77b-4a0d-f096-08d5db896f35 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:CO1PR15MB1077; X-Microsoft-Exchange-Diagnostics: 1; CO1PR15MB1077; 3:qLzQqJ3+Wdz35h2EPvl80rOJv1hDHv/vJOa328//dN7r9moBNKVHvBFTCd15uiqlZRXoO0C4UZZ6TLTvfqVh5Nyob82P2n6dw3K35tWCmua4DfbrVdrwaeKkojVi9l1ZqpeirUiC1k2lH+xIncAyz8ewPXw4cjJO5i+xoQCdD5kKmKvBGbknMdCcCu6kNv2Bf7sxyGefKRuwwbqjdHylS8RvaayQr4WlVrrVTegwWpMFYvyN1kWCxTpKDKs8lVGY; 25:4jKLg58f8nVRhA44Ru4oQRdDLzXakMx6n1543L4YvA25d3VGvm6bDdx8gcVE+hwoelwO3mDuiO2sPAuqF22JHW2zx8OekeEYJGJMl10UQmuMmZyEZYMK8l6Udn8XlWnDvIMwxWYenIxDOI90lg+puKV3fnFCVO4YVSmBVSvwNnnv4YubPPnqAOX/rJqRywkwGr/jZzBAMnKD6R//QUFN2tj9aH3cChQkpQE48JlO0uC5/oI1Bjopw6xHKnDieSN5WmO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toHUFIYPspO/eR140yfvBwqvmoZ+ZRM+vfgXZ79l+vETgFRiu8iVtgw05cMJSFSJgEsVsTvRwPNz3P7b9yvoK4gZSKRaf+/CiyEWKUikmT69P8LmeKeT0g5tTfd8sBd8VH9prhcxwrfUfkwIqVQi+D+Wr3Bi9PmzKFpVvPmbIRzIQqCl+/58PSqCYBKr3ZQcf7Ph9EDTn2L1ECipjuQTkj78VE 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)(8121501046)(5005006)(93006095)(93001095)(3231254)(11241501184)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:CO1PR15MB1077; BCL:0; PCL:0; RULEID:; SRVR:CO1PR15MB1077; X-Forefront-PRVS: 071518EF63 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(39860400002)(376002)(366004)(346002)(136003)(199004)(189003)(8676002)(36756003)(81156014)(81166006)(1076002)(47776003)(53936002)(50226002)(4326008)(478600001)(305945005)(7736002)(6512007)(6666003)(5660300001)(54906003)(6486002)(25786009)(16586007)(106356001)(6916009)(53416004)(316002)(486006)(6116002)(69596002)(16526019)(186003)(76176011)(476003)(2616005)(386003)(11346002)(575784001)(6506007)(446003)(2351001)(2906002)(86362001)(97736004)(68736007)(51416003)(46003)(52396003)(14444005)(2361001)(50466002)(8936002)(52116002)(48376002)(105586002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:CO1PR15MB1077; 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-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xyGhjkkLNJUjsfy1CSUt7k0cwp8TU7WBJXv?= =?us-ascii?Q?qdDIicQzcOS8kdcnEy52Nw3B5EUwOPkDH/DqFgcgk8+v7CfEJcRgZflTc5o6?= =?us-ascii?Q?Wn6TzLVEUCqv1yLp5z51hp0gwju8sEClAXdosel8IqvnT2mMZE9eQvQNyJtm?= =?us-ascii?Q?OyMkey//G37PrKx8tTjtHbpj/QUllb9SHck35XBRnCJx4wTvH35kFGHDCfj3?= =?us-ascii?Q?4SiyMu5w43cvBMUCmknp6dK+lknim0kIRAxG2LSysv2VqzgR68n2/Fea3eUi?= =?us-ascii?Q?cJzyYHSH1ZeIuVOpVPrVsH3xPp0oAaltywDBBGc4PZYI70fXNTqPfflDiJQg?= =?us-ascii?Q?ZqyyKYTlwk9GLyw+K2pOhhqagtWlfiZoqCUEgvnpWftfkIimcDphnCi9rBwe?= =?us-ascii?Q?oFUuz6JNskO2IJh+UkiyHVTDrAAK6MDybGcMT3rojyM/S9cghG/WmPfQ7U4w?= =?us-ascii?Q?xeG6+eCzUG2H1J1GjRQils=3D?= X-Microsoft-Antispam-Message-Info: pmzOq/AuCP+bzGkHbOQjqENpWecOaIvd8npKxZqk/jamLvlSSa7u1MluYZ3bSdGnw+DOPFSv+Z9cgaehsCUnuPnc6UFmIX0DvR3Rbf9leWS/Nbq2s2xOAbQLTVcOQ6hrtHouzvrdiajT0LiUonnhKocIdGfACcnguPLGObV+WbWLYZSENyYscsg0anmFJUI6pgO3R/Sb7olmnZmzOh4iCq85p36e5LVLdpLo73timgvMQobSbXyn2I0II5+V0isb2Dv0zOqv7GySKzihWQRXqvVt3E1jSPa0bWIQSFEsPxYCTmAJF+3f17YmzLwZdov8H7v0M4NXDltTD6A0KwYAjQgTiQ/YeMl3thw8rwr+7wM= X-Microsoft-Exchange-Diagnostics: 1; CO1PR15MB1077; 6:sl1/KAazpSB70ktV45zHLf9uBmYdnJe+qcMdYhonPN+5WDPU45BxVS4dayyOqReouWduCef6GRlm5bv5YCol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79SsNLnFjAAxz6Rgnbs7hjmjxt5vai2njgZpHsgMIvGtxiejRzzW7bWQ5FEuJ/22O4QOyxd//CPtscOEjoMytr4kJ58tbFZXD8bGPpQmcqE4On0= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2018 17:22:46.2689 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 50039075-f77b-4a0d-f096-08d5db896f35 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR15MB1077 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 cleanup 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: 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; }