In commit
2fc8d6d the behaviour of function rte_is_power_of_2 was
changed to not return true for 0. memzone_reserve_aligned_thread_unsafe
and rte_malloc_socket both make the assumption that for align = 0
!rte_is_power_of_2(align) will return false. This patch adds a check
that align parameter is non-zero before doing the power of 2 check.
Signed-off-by: Declan Doherty <declan.doherty@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
[Thomas: use && operator instead of ternary ?: and fix precedence with parens]
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
}
/* if alignment is not a power of two */
- if (!rte_is_power_of_2(align)) {
+ if (align && !rte_is_power_of_2(align)) {
RTE_LOG(ERR, EAL, "%s(): Invalid alignment: %u\n", __func__,
align);
rte_errno = EINVAL;
void *ret;
/* return NULL if size is 0 or alignment is not power-of-2 */
- if (size == 0 || !rte_is_power_of_2(align))
+ if (size == 0 || (align && !rte_is_power_of_2(align)))
return NULL;
if (socket_arg == SOCKET_ID_ANY)