From b1ccb095e4d027dad9d72bcf552a06fc8b8b2fef Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 8 May 2018 11:06:01 -0700 Subject: [PATCH] env: Explicitly fail calls to spdk_malloc with flags of 0 Passing no flags to spdk_malloc is not a valid usage. Instead, just call POSIX malloc. Change-Id: I759e2c0c0befeb4983df953edd1529d6359b4c55 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/410479 Reviewed-by: Daniel Verkamp Reviewed-by: Dariusz Stojaczyk Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System --- include/spdk/env.h | 1 + lib/env_dpdk/env.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/spdk/env.h b/include/spdk/env.h index e735d80d98..83903b96d3 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -94,6 +94,7 @@ struct spdk_env_opts { * \param socket_id Socket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY * for any socket. * \param flags Combination of SPDK_MALLOC flags (\ref SPDK_MALLOC_DMA, \ref SPDK_MALLOC_SHARE). + * At least one flag must be specified. * * \return a pointer to the allocated memory buffer. */ diff --git a/lib/env_dpdk/env.c b/lib/env_dpdk/env.c index 93f6272940..426fad4c66 100644 --- a/lib/env_dpdk/env.c +++ b/lib/env_dpdk/env.c @@ -65,6 +65,10 @@ virt_to_phys(void *vaddr) void * spdk_malloc(size_t size, size_t align, uint64_t *phys_addr, int socket_id, uint32_t flags) { + if (flags == 0) { + return NULL; + } + void *buf = rte_malloc_socket(NULL, size, align, socket_id); if (buf && phys_addr) { *phys_addr = virt_to_phys(buf);