Skip to content

Commit

Permalink
fbarray: fix log message on truncation error
Browse files Browse the repository at this point in the history
[ upstream commit 2a2ebea ]

When file truncation fails, the log message attempts to print a path of
file we failed to truncate, but this path was never set to anything and,
what's worse, was uninitialized. Fix it by passing path from the caller.

Coverity issue: 366122
Fixes: c44d098 ("eal: add shared indexed file-backed array")

Reported-by: Andrew Boyer <aboyer@pensando.io>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
  • Loading branch information
anatolyburakov authored and cpaelzer committed May 11, 2021
1 parent 0611571 commit 87ec379
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/librte_eal/common/eal_common_fbarray.c
Expand Up @@ -80,9 +80,8 @@ get_used_mask(void *data, unsigned int elt_sz, unsigned int len)
}

static int
resize_and_map(int fd, void *addr, size_t len)
resize_and_map(int fd, const char *path, void *addr, size_t len)
{
char path[PATH_MAX];
void *map_addr;

if (ftruncate(fd, len)) {
Expand Down Expand Up @@ -794,7 +793,7 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len,
goto fail;
}

if (resize_and_map(fd, data, mmap_len))
if (resize_and_map(fd, path, data, mmap_len))
goto fail;
}
ma->addr = data;
Expand Down Expand Up @@ -900,7 +899,7 @@ rte_fbarray_attach(struct rte_fbarray *arr)
goto fail;
}

if (resize_and_map(fd, data, mmap_len))
if (resize_and_map(fd, path, data, mmap_len))
goto fail;

/* store our new memory area */
Expand Down

0 comments on commit 87ec379

Please sign in to comment.