summaryrefslogtreecommitdiff
path: root/drivers/net/ena
diff options
context:
space:
mode:
authorRafal Kozik <rk@semihalf.com>2018-06-07 11:43:18 +0200
committerFerruh Yigit <ferruh.yigit@intel.com>2018-06-14 19:27:50 +0200
commit46916aa17d4b2007df8c0454f99ba0ca8b8cb93b (patch)
treedcc164ea321ef732afb2ed413eaeba57e9e5c9a8 /drivers/net/ena
parentba82e010df880467418b9bffe20275a394af414e (diff)
downloaddpdk-next-eventdev-46916aa17d4b2007df8c0454f99ba0ca8b8cb93b.zip
dpdk-next-eventdev-46916aa17d4b2007df8c0454f99ba0ca8b8cb93b.tar.gz
dpdk-next-eventdev-46916aa17d4b2007df8c0454f99ba0ca8b8cb93b.tar.xz
net/ena: check pointer before memset
Need to check if memory allocation succeed before using it. Using memset on NULL pointer cause segfault. Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK") Cc: stable@dpdk.org Signed-off-by: Rafal Kozik <rk@semihalf.com> Acked-by: Michal Krawczyk <mk@semihalf.com>
Diffstat (limited to 'drivers/net/ena')
-rw-r--r--drivers/net/ena/base/ena_plat_dpdk.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index e2af4ee..d30153e 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -210,10 +210,15 @@ extern uint32_t ena_alloc_cnt;
"ena_alloc_%d", ena_alloc_cnt++); \
mz = rte_memzone_reserve(z_name, size, SOCKET_ID_ANY, \
RTE_MEMZONE_IOVA_CONTIG); \
- memset(mz->addr, 0, size); \
- virt = mz->addr; \
- phys = mz->iova; \
handle = mz; \
+ if (mz == NULL) { \
+ virt = NULL; \
+ phys = 0; \
+ } else { \
+ memset(mz->addr, 0, size); \
+ virt = mz->addr; \
+ phys = mz->iova; \
+ } \
} while (0)
#define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, handle) \
({ ENA_TOUCH(size); ENA_TOUCH(phys); \
@@ -230,9 +235,14 @@ extern uint32_t ena_alloc_cnt;
"ena_alloc_%d", ena_alloc_cnt++); \
mz = rte_memzone_reserve(z_name, size, node, \
RTE_MEMZONE_IOVA_CONTIG); \
- memset(mz->addr, 0, size); \
- virt = mz->addr; \
- phys = mz->iova; \
+ if (mz == NULL) { \
+ virt = NULL; \
+ phys = 0; \
+ } else { \
+ memset(mz->addr, 0, size); \
+ virt = mz->addr; \
+ phys = mz->iova; \
+ } \
(void)mem_handle; \
} while (0)