[PATCH v2] common/mlx5: fix the sysfs port name translation
Stephen Hemminger
stephen at networkplumber.org
Wed Mar 22 15:58:42 CET 2023
On Wed, 22 Mar 2023 13:34:12 +0200
Bing Zhao <bingz at nvidia.com> wrote:
> +
> + port_name = (char *)malloc(IF_NAMESIZE);
> + if (port_name == NULL) {
> + fclose(file);
> + rte_errno = ENOMEM;
> + return -rte_errno;
> + }
> + line_size = getline(&port_name, &port_name_size, file);
This code is doing unnecessary extra work here.
From getline() man page:
If *lineptr is set to NULL before the call, then getline() will
allocate a buffer for storing the line. This buffer should be
freed by the user program even if getline() failed.
More information about the stable
mailing list