[PATCH v4 02/11] mem: avoid hugepage path overflow
David Marchand
david.marchand at redhat.com
Fri Feb 6 09:12:50 CET 2026
On Thu, 5 Feb 2026 at 22:30, Thomas Monjalon <thomas at monjalon.net> wrote:
> @@ -446,8 +447,14 @@ find_numasocket(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi)
> return 0;
> }
>
> - snprintf(hugedir_str, sizeof(hugedir_str),
> - "%s/%s", hpi->hugedir, eal_get_hugefile_prefix());
> + ret = asprintf(&hugedir_str, "%s/%s",
> + hpi->hugedir, eal_get_hugefile_prefix());
> + if (ret < 0) {
> + EAL_LOG(ERR, "%s(): failed to store hugepage path", __func__);
> + goto error;
On asprintf failure, hugedir_str content is undefined.
It is safer to reset hugedir_str to NULL before jumping to the error
label where free() is called.
--
David Marchand
More information about the dev
mailing list