DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Chengwen Feng <fengchengwen@huawei.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	 Bruce Richardson <bruce.richardson@intel.com>
Cc: ferruh.yigit@xilinx.com,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	 Nithin Dabilpuram <ndabilpuram@marvell.com>,
	 Kiran Kumar Kokkilagadda <kirankumark@marvell.com>,
	Sunil Kumar Kori <skori@marvell.com>,
	 Satha Rao <skoteshwar@marvell.com>, dev <dev@dpdk.org>,
	 Kevin Laatz <kevin.laatz@intel.com>,
	Conor Walsh <conor.walsh@intel.com>,
	 Ciara Power <ciara.power@intel.com>
Subject: Re: [PATCH 2/3] ethdev: fix memory leak when telemetry xstats
Date: Thu, 21 Apr 2022 10:09:56 +0200	[thread overview]
Message-ID: <CAJFAV8yHnuQo47=uGw3-XL0dheUsZ84LDnXi81ARn6XF3NPaVA@mail.gmail.com> (raw)
In-Reply-To: <20220416010747.40714-3-fengchengwen@huawei.com>

On Sat, Apr 16, 2022 at 3:14 AM Chengwen Feng <fengchengwen@huawei.com> 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 <fengchengwen@huawei.com>
> ---
>  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


  parent reply	other threads:[~2022-04-21  8:10 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-16  1:07 [PATCH 0/3] bugfix for ethdev telemetry Chengwen Feng
2022-04-16  1:07 ` [PATCH 1/3] ethdev: fix telemetry xstats return null with some PMDs Chengwen Feng
2022-04-16  1:38   ` Stephen Hemminger
2022-04-21  6:49     ` Andrew Rybchenko
2022-04-24  3:44       ` fengchengwen
2022-04-25 10:16         ` Morten Brørup
2022-04-28 13:38           ` fengchengwen
2022-04-28 13:53             ` Morten Brørup
2022-04-16  1:07 ` [PATCH 2/3] ethdev: fix memory leak when telemetry xstats Chengwen Feng
2022-04-21  6:51   ` Andrew Rybchenko
2022-04-21  8:09   ` David Marchand [this message]
2022-04-21  9:03     ` Bruce Richardson
2022-04-22  8:14       ` David Marchand
2022-04-16  1:07 ` [PATCH 3/3] net/cnxk: fix telemetry possible null pointer access Chengwen Feng
2022-04-28 13:15 ` [PATCH v2 0/9] bugfix for ethdev telemetry Chengwen Feng
2022-04-28 13:15   ` [PATCH v2 1/9] ethdev: define retval when xstats is null of get xstats Chengwen Feng
2022-05-04 10:32     ` Andrew Rybchenko
2022-04-28 13:15   ` [PATCH v2 2/9] net/hns3: adjust " Chengwen Feng
2022-05-06  7:56     ` Min Hu (Connor)
2022-04-28 13:15   ` [PATCH v2 3/9] net/ipn3ke: " Chengwen Feng
2022-04-28 13:15   ` [PATCH v2 4/9] net/mvpp2: " Chengwen Feng
2022-04-28 13:15   ` [PATCH v2 5/9] net/axgbe: " Chengwen Feng
2022-04-28 13:15   ` [PATCH v2 6/9] ethdev: fix memory leak when telemetry xstats Chengwen Feng
2022-04-28 13:15   ` [PATCH v2 7/9] ethdev: support auto-filled flag when telemetry stats Chengwen Feng
2022-04-28 13:15   ` [PATCH v2 8/9] ethdev: fix possible null pointer access Chengwen Feng
2022-04-28 13:16   ` [PATCH v2 9/9] net/cnxk: fix telemetry " Chengwen Feng
2022-05-05  8:02 ` [PATCH v3 00/10] bugfix for ethdev telemetry Chengwen Feng
2022-05-05  8:02   ` [PATCH v3 01/10] ethdev: define retval when xstats is null of get xstats Chengwen Feng
2022-05-05  8:02   ` [PATCH v3 02/10] ethdev: optimize xstats-get API's implementation Chengwen Feng
2022-05-12 10:31     ` Andrew Rybchenko
2022-05-05  8:02   ` [PATCH v3 03/10] net/hns3: adjust retval when xstats is null of get xstats Chengwen Feng
2022-05-12  9:51     ` Andrew Rybchenko
2022-05-05  8:02   ` [PATCH v3 04/10] net/ipn3ke: " Chengwen Feng
2022-05-05  8:02   ` [PATCH v3 05/10] net/mvpp2: " Chengwen Feng
2022-05-05  8:02   ` [PATCH v3 06/10] net/axgbe: " Chengwen Feng
2022-05-12 10:00     ` Andrew Rybchenko
2022-05-05  8:02   ` [PATCH v3 07/10] ethdev: fix memory leak when telemetry xstats Chengwen Feng
2022-05-05  8:02   ` [PATCH v3 08/10] ethdev: support auto-filled flag when telemetry stats Chengwen Feng
2022-05-12 10:26     ` Andrew Rybchenko
2022-05-05  8:02   ` [PATCH v3 09/10] ethdev: fix possible null pointer access Chengwen Feng
2022-05-12 10:29     ` Andrew Rybchenko
2022-05-05  8:02   ` [PATCH v3 10/10] net/cnxk: fix telemetry " Chengwen Feng
2022-05-12 10:30     ` Andrew Rybchenko
2022-05-13  2:53 ` [PATCH v4 0/9] bugfix for ethdev telemetry Chengwen Feng
2022-05-13  2:53   ` [PATCH v4 1/9] ethdev: specify return value of xstats-get API Chengwen Feng
2022-05-13  2:53   ` [PATCH v4 2/9] ethdev: optimize xstats-get API's implementation Chengwen Feng
2022-05-13  2:53   ` [PATCH v4 3/9] net/hns3: adjust return value of xstats-get ops Chengwen Feng
2022-05-13  2:53   ` [PATCH v4 4/9] net/ipn3ke: " Chengwen Feng
2022-05-13  2:53   ` [PATCH v4 5/9] net/mvpp2: " Chengwen Feng
2022-05-13  2:53   ` [PATCH v4 6/9] net/axgbe: " Chengwen Feng
2022-05-13  2:53   ` [PATCH v4 7/9] ethdev: fix memory leak when telemetry xstats Chengwen Feng
2022-05-13  2:53   ` [PATCH v4 8/9] ethdev: fix possible null pointer access Chengwen Feng
2022-05-13  2:53   ` [PATCH v4 9/9] net/cnxk: fix telemetry " Chengwen Feng
2022-05-16  8:43   ` [PATCH v4 0/9] bugfix for ethdev telemetry Morten Brørup
2022-05-20 14:50     ` Andrew Rybchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJFAV8yHnuQo47=uGw3-XL0dheUsZ84LDnXi81ARn6XF3NPaVA@mail.gmail.com' \
    --to=david.marchand@redhat.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bruce.richardson@intel.com \
    --cc=ciara.power@intel.com \
    --cc=conor.walsh@intel.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=ferruh.yigit@xilinx.com \
    --cc=kevin.laatz@intel.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).