net/ice/base: check memory pointer before copying
PATCH 1/1 net/ice/base: check memory pointer before copying
The ice_memdup doesn't check the new allocated memory pointer, it calls the rte_memcpy directly. It should check it.
Fixes 5f0978e96220 ("net/ice/base: add OS specific implementation")
Signed-off-by Haiyue Wang <[email protected]>
--- drivers/net/ice/base/ice_osdep.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/net/ice/base/ice_osdep.h +15 -1
@@ -24,6 +24,8 @@#include <rte_random.h> #include <rte_io.h> +#include "ice_alloc.h" +#include "../ice_logs.h" #ifndef __INTEL_NET_BASE_OSDEP__
@@ -193,7 +195,6 @@ struct ice_virt_mem {#define ice_memset (a, b, c, d) memset((a), (b), (c))#define ice_memcpy (a, b, c, d) rte_memcpy((a), (b), (c)) -#define ice_memdup (a, b, c, d) rte_memcpy(ice_malloc(a, c), b, c)/* SW spinlock */ struct ice_lock {
@@ -225,6 +226,19 @@ ice_destroy_lock(__attribute__((unused)) struct ice_lock *sp)struct ice_hw ; +static __rte_always_inline void * +ice_memdup(__rte_unused struct ice_hw *hw, const void *src, size_t size, + __rte_unused enum ice_memcpy_type dir) +{ +void *p; + + p =ice_malloc (hw, size); +if (p) +rte_memcpy (p, src, size); + +return p; +} +static inline void *ice_alloc_dma_mem (__attribute__((unused))struct ice_hw *hw,struct ice_dma_mem *mem,u64 size)
Signature · 1 line
2.26.0
Quoted 49 lines · Haiyue Wang
The
ice_memdupdoesn't check the new allocated memory pointer, it calls therte_memcpydirectly. It should check it.Fixes 5f0978e96220 ("net/ice/base: add OS specific implementation")Signed-off-by Haiyue Wang <[email protected]>---
drivers/net/ice/base/ice_osdep.h| 16 +++++++++++++++-1 file changed, 15 insertions(+), 1 deletion(-)drivers/net/ice/base/ice_osdep.h +15
-1@@ -24,6 +24,8 @@#include <rte_random.h> #include <rte_io.h> +#include "ice_alloc.h" +#include "../ice_logs.h" #ifndef __INTEL_NET_BASE_OSDEP__@@ -193,7 +195,6 @@ struct ice_virt_mem {#define ice_memset (a, b, c, d) memset((a), (b), (c))#define ice_memcpy (a, b, c, d) rte_memcpy((a), (b), (c)) -#define ice_memdup (a, b, c, d) rte_memcpy(ice_malloc(a, c), b, c)/* SW spinlock */ struct ice_lock {@@ -225,6 +226,19 @@ ice_destroy_lock(__attribute__((unused)) struct ice_lock *sp)struct ice_hw ; +static __rte_always_inline void * +ice_memdup(__rte_unused struct ice_hw *hw, const void *src, size_t size, + __rte_unused enum ice_memcpy_type dir) +{ +void *p; + + p =ice_malloc (hw, size); +if (p) +rte_memcpy (p, src, size); + +return p; +} +
Quoted 6 lines
static inline void * ice_alloc_dma_mem(__attribute__((unused)) struct
ice_hw*hw,
structice_dma_mem*mem, u64 size)Signature · 1 line
2.26.0
Reviewed-by Xiaolong Ye <[email protected]>
Applied to dpdk-next-net-intel, Thanks.