Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp240036ybi; Wed, 29 May 2019 20:26:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWtl4X1U+6PuJ8lTJKGySI3J118FVt5i7qVol3VCgbNBRJC7ywtYnkGgE47RqO/B5FbHNw X-Received: by 2002:a65:458f:: with SMTP id o15mr1669796pgq.376.1559186783051; Wed, 29 May 2019 20:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559186783; cv=none; d=google.com; s=arc-20160816; b=IqrhW9uBhGvemOAHLFKxS62qVaJkv4aKANropjfI/KP/nO7AW0fqJCksmcIH5nhDqg 4b/JE4D9FYMRNr1m4uB1iQ235gFtZYlEVL0caRQ24uY6YMyh6LfZyEv+0W0m+Crp+ZC4 Ho+qoISjHN74wvC6JMc236mnElFAY1gorfBh9IGa7zqBW0Kl0s+Khf3zJVkNstxH0TH0 EfAX48NIro+vvRnPP+Nxtwf9/YzViQT9gH3KURx/RbtLCGokg05JA/lqDvY/kLAqfCSV g7GjDgzFWd8zvEfNL+DGXsogcQCEe5c828prSCbXP1TuOirnG5R3qM02Tp2IAwxqmxkA ni+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8DCWdxfUxMlM8NCSdaK1N1x6lk/+n01CjWkIDu1kRDc=; b=utG8xJkmKXI+2YIWwj31ESaHEQxvFuikRPItw82yTs5HvPd+LsCv+v8uljPTVF9JuZ YrHtksKU+xG09AFuxbTD+fxk4HcSgNAjF2KCHLCq/N6YdyKJ7iUqEBka1kL83DXYISNd ZEjMUOBwnq/TcC6doAtuPAJzW0Iwd6UX1hFVgQYpqKcrJYc4oYTX0fOdjKsfgwwxgvR/ P4Ic6PdRakgyY0429chgSGVpqb3nnKAD54/t41iI0zIDKSAdSzZBnuSSGLp7lxi6RhQ9 j1jclUkOpMGRPCwN6ygxfmJFZR7bUAskCwMit57/0BuLvJ9n09arrd5RiG9QgBU6XAnI AYqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YQAw5qDi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si2051980plg.320.2019.05.29.20.26.08; Wed, 29 May 2019 20:26:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YQAw5qDi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733243AbfE3DYR (ORCPT + 99 others); Wed, 29 May 2019 23:24:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:49014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731307AbfE3DRx (ORCPT ); Wed, 29 May 2019 23:17:53 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BDDA24733; Thu, 30 May 2019 03:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186272; bh=iGxECOeYoMheEdkjkj36hyuYRAMoQSKnz47vNcgJL9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YQAw5qDiUa0a0FPmJI6xh9XQ2ppv7FB97YPwQXFYiAOdc6uDsNDzSEqSK8OvNGvJl cFYWbyKUZd4wsN3i3HRIY77HF2CvpNRonQNMNIPSEcFg9H8YSDNTfeHRc06uGCo8L8 +6qFkWhkeLbPxy4LZjxb/OFWXaUWp0HaEnfsUUn8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roman Gushchin , Dan Carpenter , "Shuah Khan (Samsung OSG)" , Mike Rapoport , Sasha Levin Subject: [PATCH 4.19 177/276] selftests: cgroup: fix cleanup path in test_memcg_subtree_control() Date: Wed, 29 May 2019 20:05:35 -0700 Message-Id: <20190530030536.382969778@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit e14d314c7a489f060d6d691866fef5f131281718 ] 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 Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin --- .../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 28d321ba311b4..6f339882a6ca1 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -26,7 +26,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]; @@ -34,50 +34,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; } -- 2.20.1