Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp111775ybg; Mon, 8 Jun 2020 17:56:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZwYSBF/m7fM7R8gnlFNCHdRKjCGfk7avou7BDQeuhmQwrKglL3go0sJp0nWg+foLk9pLL X-Received: by 2002:a17:906:5e05:: with SMTP id n5mr22859062eju.278.1591664190212; Mon, 08 Jun 2020 17:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664190; cv=none; d=google.com; s=arc-20160816; b=StroUcD4pMZ6CmDRq72m3b7KOBP8vkomeDxS4xaQM7uePWdKEcTt7Xc5vc0kT1hKGu 1N1xbxwMhO+GEGUdWdcCV0HLKddRw3fUvH4Fmi6OfTU+AWM3FZX+UGpo+TjxPG4DWHul PwyGyjRQP2oTqyeYNfGKeCU6Exspvu8Uc3GQx5d6AFIBrR14s+21WbNMtIVNBh0u+BFP lrB79JLYJqY/1dSitSNC0CXRn2FmgO5VCIJwxbmSZ3AgVKWQdqkJlsrOQPozWAjxacI+ i05GluAvEPMcYgz7fq9Thb6JU+Dcj9IfNbsZ1XmZ5rbiGe0MDr38jyaDeRBRy5D6VXWk nDVg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2/vyxFvjblpfPF6pxn4uBd3rDYpRZ7CY9svRvDJR/H0=; b=SndK2nt9qC3JLutaO/v+SK1mlOTTbubWPKU8Ul7ALjktTor4h1lFrBRi7y1AgvU3Cs EFuxhMNBkttgIEF0hYxUkcq3+lDLEzKZwM4kS/hL394I6A7LHchXAdJ3E8vLFYim8FN3 bYs+DU1cYDWV5Wono/kbfM6eVTAkLIWxC/GRVoq1YQt9MdbumCXQdkBuOTjvxvrFe3kO fm4M8Nm4n04Hex5gzPnwzuTE4WqGi2UCVDxhp0mU/EsvydyIngPp8V/ii8xqRqVV6lz/ 6oD8f08s/2mszCKR7UCHv3NzV0XSLX6iVAOeFzKY2fmg0CaThfaMJOGj5Raz5Xiy3osM yoPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IroOBB1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f6si9662905ejr.283.2020.06.08.17.56.07; Mon, 08 Jun 2020 17:56:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IroOBB1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728548AbgFHXKB (ORCPT + 99 others); Mon, 8 Jun 2020 19:10:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:54628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728314AbgFHXJC (ORCPT ); Mon, 8 Jun 2020 19:09:02 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB0CB208E4; Mon, 8 Jun 2020 23:09:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657741; bh=t8EX+OcVvPjkVogK7HTxyL6ukX9m/HBgPkG41B/CT7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IroOBB1iUIAbfWFEHwfez+w4FimyjYl1vuD59NknoZ2ENcif8Ul+4Z7s9EM+6mNXx OdNuQ9pXXqiVIg/He419YAyJvdXbpePYsXTJUHCaSXxKlxdJnJGNLAC5+ci33MozDM 8S4O/QBqADEG0DZtfGNkdVyHBR/7e6zUNrS2TKGA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrii Nakryiko , Alexei Starovoitov , Sasha Levin , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 130/274] selftests/bpf: Fix memory leak in test selector Date: Mon, 8 Jun 2020 19:03:43 -0400 Message-Id: <20200608230607.3361041-130-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrii Nakryiko [ Upstream commit f25d5416d64c796aa639136eb0b076c8bd579b54 ] Free test selector substrings, which were strdup()'ed. Fixes: b65053cd94f4 ("selftests/bpf: Add whitelist/blacklist of test names to test_progs") Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20200429012111.277390-6-andriin@fb.com Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/test_progs.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index b521e0a512b6..86d0020c9eec 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -420,6 +420,18 @@ static int libbpf_print_fn(enum libbpf_print_level level, return 0; } +static void free_str_set(const struct str_set *set) +{ + int i; + + if (!set) + return; + + for (i = 0; i < set->cnt; i++) + free((void *)set->strs[i]); + free(set->strs); +} + static int parse_str_list(const char *s, struct str_set *set) { char *input, *state = NULL, *next, **tmp, **strs = NULL; @@ -756,11 +768,11 @@ int main(int argc, char **argv) fprintf(stdout, "Summary: %d/%d PASSED, %d SKIPPED, %d FAILED\n", env.succ_cnt, env.sub_succ_cnt, env.skip_cnt, env.fail_cnt); - free(env.test_selector.blacklist.strs); - free(env.test_selector.whitelist.strs); + free_str_set(&env.test_selector.blacklist); + free_str_set(&env.test_selector.whitelist); free(env.test_selector.num_set); - free(env.subtest_selector.blacklist.strs); - free(env.subtest_selector.whitelist.strs); + free_str_set(&env.subtest_selector.blacklist); + free_str_set(&env.subtest_selector.whitelist); free(env.subtest_selector.num_set); return env.fail_cnt ? EXIT_FAILURE : EXIT_SUCCESS; -- 2.25.1