From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A7621A00C3; Thu, 21 Apr 2022 10:10:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A30940042; Thu, 21 Apr 2022 10:10:13 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 079CC40040 for ; Thu, 21 Apr 2022 10:10:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650528610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xCNvB95OyK48Gn20R3rlmx32ZzErtthNF5E+Kk9T1p8=; b=fYlXS5kBsDLH8zMoxAhSI69ct0Y0g91gT7GeO909QdS5lHoYezCBMGag7uescd5xaNhcPF UhkqJCAf9hsOSxv3K1LbPO4s6C997ylnJJQmU7kDRkimO5MTi/AuuxzTusU8R7aD/JtFPd BZP4lVdqjhgpolmdbkJRbneVMQmFrGA= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-317-pIFb37sBNNirt1HYWrIdzw-1; Thu, 21 Apr 2022 04:10:09 -0400 X-MC-Unique: pIFb37sBNNirt1HYWrIdzw-1 Received: by mail-lf1-f69.google.com with SMTP id y20-20020a197514000000b0046cbe2da153so1540232lfe.19 for ; Thu, 21 Apr 2022 01:10:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xCNvB95OyK48Gn20R3rlmx32ZzErtthNF5E+Kk9T1p8=; b=AXcg0TTQoJTGM3T81UuBIevUkeBHKTpXIxdosyU1G2F0MHFH/cUaC5Ykpjxa6134kN 7PELvFjTGsjXzlc/xwBQS+ZkRtdfv2vU7acRwY239PDKGXO7kjpl5nc1DlMUgVV3QXm6 noLD3beCF/Uqvg4MOFhcYOQaihiLhobbbASv4gewEoWiasQDxEwIG/rnr2DsMj9j6ovH MtvsVNSPLG5MDqrMZVHI6UD6fCaj6RaADLm5OJxSasadTPfvJJ7P8/7vS8h0IKs1sXtt om8X/wcf1OiKNk0PTTVRcw/a4hMF2Wi9/dnrARK6nvMzECUMbLV3Jp8+px4mtagWBP7W sgug== X-Gm-Message-State: AOAM532DzNh9zSCOANJEtSxKIAX/7o7GZh02g59GxZcH6EHFq6Rd6sVc +CnRlQe9yNsh2Au9Ruy3Z4W383fovUKMCcSVTgZrhijYSYpmEpM+7h+t8h9DEGdzDwJ42NY/eUE V/O+W5yyA97txKtQ2jvU= X-Received: by 2002:ac2:4573:0:b0:46d:7f8:6c2b with SMTP id k19-20020ac24573000000b0046d07f86c2bmr17166455lfm.265.1650528607912; Thu, 21 Apr 2022 01:10:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDv029wS0Kwgwk2TgE8VvfDdb0CNZ/lhLqY4zu905is8VKy+XgLHfhb6e+X53FKcGCjTitK5eQvlK3LTsJ0Nw= X-Received: by 2002:ac2:4573:0:b0:46d:7f8:6c2b with SMTP id k19-20020ac24573000000b0046d07f86c2bmr17166441lfm.265.1650528607708; Thu, 21 Apr 2022 01:10:07 -0700 (PDT) MIME-Version: 1.0 References: <20220416010747.40714-1-fengchengwen@huawei.com> <20220416010747.40714-3-fengchengwen@huawei.com> In-Reply-To: <20220416010747.40714-3-fengchengwen@huawei.com> From: David Marchand Date: Thu, 21 Apr 2022 10:09:56 +0200 Message-ID: Subject: Re: [PATCH 2/3] ethdev: fix memory leak when telemetry xstats To: Chengwen Feng , Thomas Monjalon , Bruce Richardson Cc: ferruh.yigit@xilinx.com, Andrew Rybchenko , Nithin Dabilpuram , Kiran Kumar Kokkilagadda , Sunil Kumar Kori , Satha Rao , dev , Kevin Laatz , Conor Walsh , Ciara Power Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Sat, Apr 16, 2022 at 3:14 AM Chengwen Feng wrote: > > The 'eth_xstats' should be freed after setup telemetry dictionary. This > patch fixes it. > > Fixes: c190daedb9b1 ("ethdev: add telemetry callbacks") > Cc: stable@dpdk.org > > Signed-off-by: Chengwen Feng > --- > lib/ethdev/rte_ethdev.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > index 615383bde2..df20433c2d 100644 > --- a/lib/ethdev/rte_ethdev.c > +++ b/lib/ethdev/rte_ethdev.c > @@ -5585,6 +5585,7 @@ eth_dev_handle_port_xstats(const char *cmd __rte_unused, > for (i = 0; i < num_xstats; i++) > rte_tel_data_add_dict_u64(d, xstat_names[i].name, > eth_xstats[i].value); > + free(eth_xstats); > return 0; > } > We need some minimal testing for telemetry commands. It could be a test automatically calling all available /ethdev/ commands on a running testpmd. This test could be really simple, not even checking what is returned. It would just try every command sequentially with no parameter first, then with port 0 and finally with port 1. Coupled with ASan in the CI, this current issue would have been caught. For example, I tested manually with testpmd + net/null ports: ==3825787==ERROR: LeakSanitizer: detected memory leaks Direct leak of 1040 byte(s) in 1 object(s) allocated from: #0 0x7f7048a2d91f in __interceptor_malloc (/usr/lib64/libasan.so.6+0xae91f) #1 0x32859e9 in eth_dev_handle_port_xstats (/home/dmarchan/dpdk/build-gcc-asan/app/dpdk-testpmd+0x32859e9) #2 0x3346ac9 in perform_command (/home/dmarchan/dpdk/build-gcc-asan/app/dpdk-testpmd+0x3346ac9) #3 0x3347a8e in client_handler (/home/dmarchan/dpdk/build-gcc-asan/app/dpdk-testpmd+0x3347a8e) #4 0x7f7045751b19 in start_thread /usr/src/debug/glibc-2.34-25.fc35.x86_64/nptl/pthread_create.c:443 Opinions? -- David Marchand