Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3523895rwb; Sun, 9 Oct 2022 06:37:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4KgWuZDAT5Yt0s3uxpdmGpaWQoFSomr+Z32o9LcEhYMNst7DIiwdHwinc44lz+wM6G3b89 X-Received: by 2002:a05:6a00:3392:b0:547:f861:1fad with SMTP id cm18-20020a056a00339200b00547f8611fadmr14914102pfb.16.1665322635564; Sun, 09 Oct 2022 06:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665322635; cv=none; d=google.com; s=arc-20160816; b=Q6SexbA+Z56TLAQsZ5wwyj3qxWjmXLQ9Rayf3S2yrBvrTLzEU3+EnpqY4jq4NjpVlO QkFIxaV6t46J6On0XL9+dfxlnz3bTNQbG0897r9N+mVEbsHfYIN1ZD7FO0MZvcxEZrc9 f1JwFnxJ9ycRg09yWHPKeWH+hVM74pIL6kM7hjZb3X4oTZHI7qpXYNMwqdw3RjI0Qs7A Rz0RechvXU3H1L+zS53MUMmB86FWbeojhUw0+CWs1Ff8tHU2OPdtvuaiGlYv3eVnhzNL F9X2tDWXs8oTaGIYjMBm/L1VyjPkT6uaNTPt4m40+f8Y6XFK8fhkzyuCzkI2+mJzX9Hq Oidg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=lyfltkeC13VPPzZlj3ezrZ2mwnjRrsCIwBYeQE/Z2T8=; b=WwJKG/P3qP9t4u6Q8hyEZMsCksT2tqz9e2I9hGSNulLoPQ9BdKwGMLuDBsjLdZ+JM+ 2FxRseMS2ZMmds7Mb2wIhig1WJ6qRZUdTyvvBL/186OkRVZen3DqBk/Y9y+T9k6uvkge WeLkQ4/Rs/pI2ZMroxFROZyoNt7QLV8jP3WZs4FNOB6xPpdSgfsFtYPm4clEzRLS9YTt Ph5I7bKsxeO7ZZ+9ONxNUbFLwHkohw0TF2bpFPzkTF8oJRYUWPLO/7rIt73DGMu0Y0cz vAblNCNfAMSF+9k7HNQpwVlaPDsPl2GpAy6OlMt3jp3hmTG7222mv5V2NslCeAHGGVYz rSwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u71-20020a63854a000000b004403ddda6e6si2053786pgd.847.2022.10.09.06.36.45; Sun, 09 Oct 2022 06:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbiJINB1 (ORCPT + 99 others); Sun, 9 Oct 2022 09:01:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbiJINA6 (ORCPT ); Sun, 9 Oct 2022 09:00:58 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF882A95E; Sun, 9 Oct 2022 06:00:56 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Mlhtn1Ytyz6PmS3; Sun, 9 Oct 2022 20:58:41 +0800 (CST) Received: from k01.huawei.com (unknown [10.67.174.197]) by APP2 (Coremail) with SMTP id Syh0CgDHX9T6xUJjwRQEAA--.16593S6; Sun, 09 Oct 2022 21:00:54 +0800 (CST) From: Xu Kuohai To: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , "David S . Miller" , Jakub Kicinski , Jesper Dangaard Brouer , Hou Tao , Dmitrii Dolgov <9erthalion6@gmail.com>, Alan Maguire , Kui-Feng Lee , Kumar Kartikeya Dwivedi Subject: [PATCH bpf-next 4/5] selftest/bpf: Fix memory leak in kprobe_multi_test Date: Sun, 9 Oct 2022 09:18:29 -0400 Message-Id: <20221009131830.395569-5-xukuohai@huaweicloud.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221009131830.395569-1-xukuohai@huaweicloud.com> References: <20221009131830.395569-1-xukuohai@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: Syh0CgDHX9T6xUJjwRQEAA--.16593S6 X-Coremail-Antispam: 1UD129KBjvJXoW7uFyfZw1xZw17Aw4kXw18Krg_yoW8WF43pF W0yw4Yka4xAr13X3W3GF48WFyrursrZ34UurWYvw15Cwn8Xw18GF4xKFW3KF95GrZ5Zw43 u3W5tr95Ga1UXFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBSb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1lIxAI cVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2js IEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjxUFgAwUUUUU X-CM-SenderInfo: 50xn30hkdlqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu Kuohai The get_syms() function in kprobe_multi_test.c does not free the string memory allocated by sscanf correctly. Fix it. Signed-off-by: Xu Kuohai --- .../bpf/prog_tests/kprobe_multi_test.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c index d457a55ff408..07dd2c5b7f98 100644 --- a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c +++ b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c @@ -360,15 +360,14 @@ static int get_syms(char ***symsp, size_t *cntp) * to them. Filter out the current culprits - arch_cpu_idle * and rcu_* functions. */ - if (!strcmp(name, "arch_cpu_idle")) - continue; - if (!strncmp(name, "rcu_", 4)) - continue; - if (!strcmp(name, "bpf_dispatcher_xdp_func")) - continue; - if (!strncmp(name, "__ftrace_invalid_address__", - sizeof("__ftrace_invalid_address__") - 1)) + if (!strcmp(name, "arch_cpu_idle") || + !strncmp(name, "rcu_", 4) || + !strcmp(name, "bpf_dispatcher_xdp_func") || + !strncmp(name, "__ftrace_invalid_address__", + sizeof("__ftrace_invalid_address__") - 1)) { + free(name); continue; + } err = hashmap__add(map, name, NULL); if (err) { free(name); @@ -394,7 +393,7 @@ static int get_syms(char ***symsp, size_t *cntp) hashmap__free(map); if (err) { for (i = 0; i < cnt; i++) - free(syms[cnt]); + free(syms[i]); free(syms); } return err; -- 2.25.1