From: Bruce Richardson <bruce.richardson@intel.com>
To: Anurag Mandal <anurag.mandal@intel.com>
Cc: <dev@dpdk.org>, <anatoly.burakov@intel.com>
Subject: Re: [PATCH 3/7] net/ice: fix DDP filename leak
Date: Tue, 27 Oct 2026 13:52:37 +0000 [thread overview]
Message-ID: <auCspZRzmnqU8kLE@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <85b3df3751d1e6b319c1af2cb21e01cf7db4e229.1793097896.git.anurag.mandal@intel.com>
On Tue, Oct 27, 2026 at 10:51:33AM +0000, Anurag Mandal wrote:
> The DDP package filename given with the ddp_pkg_file devarg is
> duplicated with strdup() during devargs parsing, but only freed on
> close. It leaks when ice_dev_init() fails at or after devargs
> parsing, and when the devarg is given more than once.
>
> Free the previous string before storing a new one, and free it on all
> init error paths.
>
> Fixes: 9dd6dd1db834 ("net/ice: add option to choose DDP package file")
> Fixes: 603beeb970b5 ("net/ice: add safe mode devarg")
> Fixes: f9cf4f864150 ("net/ice: support device initialization")
Cc: stable@dpdk.org
>
> Signed-off-by: Anurag Mandal <anurag.mandal@intel.com>
> ---
> drivers/net/intel/ice/ice_ethdev.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/intel/ice/ice_ethdev.c b/drivers/net/intel/ice/ice_ethdev.c
> index 27f992aefa..ec4d021ec6 100644
> --- a/drivers/net/intel/ice/ice_ethdev.c
> +++ b/drivers/net/intel/ice/ice_ethdev.c
> @@ -805,6 +805,7 @@ handle_ddp_filename_arg(__rte_unused const char *key, const char *value, void *n
> PMD_DRV_LOG(ERR, "The DDP package filename is too long : '%s'", value);
> return -1;
> }
> + free((void *)(uintptr_t)*filename);
You can avoid the casting by changing the type of filename to char * in
this function only.
> *filename = strdup(value);
> return 0;
> }
> @@ -2738,7 +2739,8 @@ ice_dev_init(struct rte_eth_dev *dev)
> ret = ice_parse_devargs(dev);
> if (ret) {
> PMD_INIT_LOG(ERR, "Failed to parse devargs");
> - return -EINVAL;
> + ret = -EINVAL;
> + goto err_free_devargs;
> }
>
> ice_init_controlq_parameter(hw);
> @@ -2746,7 +2748,8 @@ ice_dev_init(struct rte_eth_dev *dev)
> ret = ice_init_hw(hw);
> if (ret) {
> PMD_INIT_LOG(ERR, "Failed to initialize HW");
> - return -EINVAL;
> + ret = -EINVAL;
> + goto err_free_devargs;
> }
>
> /*
> @@ -2761,7 +2764,8 @@ ice_dev_init(struct rte_eth_dev *dev)
> PMD_INIT_LOG(ERR, "Invalid rl_burst_size %u bytes",
> ad->devargs.rl_burst_size);
> ice_deinit_hw(hw);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto err_free_devargs;
> }
>
> #ifndef RTE_EXEC_ENV_WINDOWS
> @@ -2912,6 +2916,9 @@ ice_dev_init(struct rte_eth_dev *dev)
> err_init_fw:
> #endif
> ice_deinit_hw(hw);
> +err_free_devargs:
> + free((void *)(uintptr_t)ad->devargs.ddp_filename);
I think this would be better using RTE_CAST_PTR, rather than using explicit
casts.
> + ad->devargs.ddp_filename = NULL;
>
> return ret;
> }
> --
> 2.25.1
>
next prev parent reply other threads:[~2026-10-27 13:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 10:51 [PATCH 0/7] net/ice: fix memory leaks Anurag Mandal
2026-10-27 10:51 ` [PATCH 1/7] net/ice: fix DDP package double free on init failure Anurag Mandal
2026-10-27 12:39 ` Bruce Richardson
2026-10-27 12:45 ` Bruce Richardson
2026-10-27 10:51 ` [PATCH 2/7] net/ice: fix memory leaks on port close Anurag Mandal
2026-10-27 13:17 ` Bruce Richardson
2026-10-27 10:51 ` [PATCH 3/7] net/ice: fix DDP filename leak Anurag Mandal
2026-10-27 13:52 ` Bruce Richardson [this message]
2026-10-27 10:51 ` [PATCH 4/7] net/ice: fix main VSI leak on init failure Anurag Mandal
2026-10-27 14:58 ` Bruce Richardson
2026-10-27 10:51 ` [PATCH 5/7] net/ice: fix MAC and VLAN filter leak on VSI release Anurag Mandal
2026-10-27 15:09 ` Bruce Richardson
2026-10-27 10:51 ` [PATCH 6/7] net/ice: fix FDIR resource leak on setup failure Anurag Mandal
2026-10-27 15:19 ` Bruce Richardson
2026-10-27 10:51 ` [PATCH 7/7] net/ice: fix ACL profile segment leak Anurag Mandal
2026-10-27 15:27 ` Bruce Richardson
2026-10-27 15:28 ` [PATCH 0/7] net/ice: fix memory leaks Bruce Richardson
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=auCspZRzmnqU8kLE@bricha3-mobl1.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=anurag.mandal@intel.com \
--cc=dev@dpdk.org \
/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