git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vfio: fix maximum number of interrupt for MSI-X
[dpdk.git]
/
lib
/
librte_eal
/
common
/
eal_common_memzone.c
diff --git
a/lib/librte_eal/common/eal_common_memzone.c
b/lib/librte_eal/common/eal_common_memzone.c
index
711c845
..
64f4e0a
100644
(file)
--- a/
lib/librte_eal/common/eal_common_memzone.c
+++ b/
lib/librte_eal/common/eal_common_memzone.c
@@
-119,6
+119,9
@@
find_heap_max_free_elem(int *s, unsigned align)
}
}
}
}
+ if (len < MALLOC_ELEM_OVERHEAD + align)
+ return 0;
+
return len - MALLOC_ELEM_OVERHEAD - align;
}
return len - MALLOC_ELEM_OVERHEAD - align;
}
@@
-126,6
+129,7
@@
static const struct rte_memzone *
memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
int socket_id, unsigned flags, unsigned align, unsigned bound)
{
memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
int socket_id, unsigned flags, unsigned align, unsigned bound)
{
+ struct rte_memzone *mz;
struct rte_mem_config *mcfg;
size_t requested_len;
int socket, i;
struct rte_mem_config *mcfg;
size_t requested_len;
int socket, i;
@@
-140,6
+144,13
@@
memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
return NULL;
}
return NULL;
}
+ if (strlen(name) > sizeof(mz->name) - 1) {
+ RTE_LOG(DEBUG, EAL, "%s(): memzone <%s>: name too long\n",
+ __func__, name);
+ rte_errno = ENAMETOOLONG;
+ return NULL;
+ }
+
/* zone already exist */
if ((memzone_lookup_thread_unsafe(name)) != NULL) {
RTE_LOG(DEBUG, EAL, "%s(): memzone <%s> already exists\n",
/* zone already exist */
if ((memzone_lookup_thread_unsafe(name)) != NULL) {
RTE_LOG(DEBUG, EAL, "%s(): memzone <%s> already exists\n",
@@
-189,8
+200,13
@@
memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
if (len == 0) {
if (bound != 0)
requested_len = bound;
if (len == 0) {
if (bound != 0)
requested_len = bound;
- else
+ else
{
requested_len = find_heap_max_free_elem(&socket_id, align);
requested_len = find_heap_max_free_elem(&socket_id, align);
+ if (requested_len == 0) {
+ rte_errno = ENOMEM;
+ return NULL;
+ }
+ }
}
if (socket_id == SOCKET_ID_ANY)
}
if (socket_id == SOCKET_ID_ANY)
@@
-223,7
+239,7
@@
memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
const struct malloc_elem *elem = malloc_elem_from_data(mz_addr);
/* fill the zone in config */
const struct malloc_elem *elem = malloc_elem_from_data(mz_addr);
/* fill the zone in config */
-
struct rte_memzone *
mz = get_next_free_memzone();
+ mz = get_next_free_memzone();
if (mz == NULL) {
RTE_LOG(ERR, EAL, "%s(): Cannot find free memzone but there is room "
if (mz == NULL) {
RTE_LOG(ERR, EAL, "%s(): Cannot find free memzone but there is room "
@@
-322,14
+338,6
@@
rte_memzone_free(const struct rte_memzone *mz)
idx = idx / sizeof(struct rte_memzone);
addr = mcfg->memzone[idx].addr;
idx = idx / sizeof(struct rte_memzone);
addr = mcfg->memzone[idx].addr;
-#ifdef RTE_LIBRTE_IVSHMEM
- /*
- * If ioremap_addr is set, it's an IVSHMEM memzone and we cannot
- * free it.
- */
- if (mcfg->memzone[idx].ioremap_addr != 0)
- ret = -EINVAL;
-#endif
if (addr == NULL)
ret = -EINVAL;
else if (mcfg->memzone_cnt == 0) {
if (addr == NULL)
ret = -EINVAL;
else if (mcfg->memzone_cnt == 0) {