diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index 395519d..48d2808 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -184,7 +184,7 @@
 		res = ibv_destroy_flow_action(attr->action);
 		break;
 	}
-	free(action);
+	mlx5_free(action);
 	return res;
 #endif
 #else
@@ -617,7 +617,7 @@
 	struct mlx5dv_flow_action_attr *action;
 
 	(void)offset;
-	action = malloc(sizeof(*action));
+	action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
 	if (!action)
 		return NULL;
 	action->type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
@@ -641,7 +641,7 @@
 #else
 	struct mlx5dv_flow_action_attr *action;
 
-	action = malloc(sizeof(*action));
+	action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
 	if (!action)
 		return NULL;
 	action->type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
@@ -686,7 +686,7 @@
 
 	(void)domain;
 	(void)flags;
-	action = malloc(sizeof(*action));
+	action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
 	if (!action)
 		return NULL;
 	action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
@@ -726,7 +726,7 @@
 	(void)flags;
 	struct mlx5dv_flow_action_attr *action;
 
-	action = malloc(sizeof(*action));
+	action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
 	if (!action)
 		return NULL;
 	action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
@@ -755,7 +755,8 @@
 	return mlx5dv_dr_action_create_tag(tag);
 #else /* HAVE_MLX5DV_DR */
 	struct mlx5dv_flow_action_attr *action;
-	action = malloc(sizeof(*action));
+
+	action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
 	if (!action)
 		return NULL;
 	action->type = MLX5DV_FLOW_ACTION_TAG;
diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c
index dc504d8..8ab7f6b 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.c
+++ b/drivers/common/mlx5/linux/mlx5_nl.c
@@ -22,6 +22,7 @@
 
 #include "mlx5_nl.h"
 #include "mlx5_common_utils.h"
+#include "mlx5_malloc.h"
 #ifdef HAVE_DEVLINK
 #include <linux/devlink.h>
 #endif
@@ -330,7 +331,7 @@ struct mlx5_nl_ifindex_data {
 	     void *arg)
 {
 	struct sockaddr_nl sa;
-	void *buf = malloc(MLX5_RECV_BUF_SIZE);
+	void *buf = mlx5_malloc(0, MLX5_RECV_BUF_SIZE, 0, SOCKET_ID_ANY);
 	struct iovec iov = {
 		.iov_base = buf,
 		.iov_len = MLX5_RECV_BUF_SIZE,
@@ -393,7 +394,7 @@ struct mlx5_nl_ifindex_data {
 		}
 	} while (multipart);
 exit:
-	free(buf);
+	mlx5_free(buf);
 	return ret;
 }
 
diff --git a/drivers/common/mlx5/mlx5_common_mp.c b/drivers/common/mlx5/mlx5_common_mp.c
index da55143..40e3956 100644
--- a/drivers/common/mlx5/mlx5_common_mp.c
+++ b/drivers/common/mlx5/mlx5_common_mp.c
@@ -11,6 +11,7 @@
 
 #include "mlx5_common_mp.h"
 #include "mlx5_common_utils.h"
+#include "mlx5_malloc.h"
 
 /**
  * Request Memory Region creation to the primary process.
@@ -49,7 +50,7 @@
 	ret = res->result;
 	if (ret)
 		rte_errno = -ret;
-	free(mp_rep.msgs);
+	mlx5_free(mp_rep.msgs);
 	return ret;
 }
 
@@ -89,7 +90,7 @@
 	mp_res = &mp_rep.msgs[0];
 	res = (struct mlx5_mp_param *)mp_res->param;
 	ret = res->result;
-	free(mp_rep.msgs);
+	mlx5_free(mp_rep.msgs);
 	return ret;
 }
 
@@ -136,7 +137,7 @@
 	DRV_LOG(DEBUG, "port %u command FD from primary is %d",
 		mp_id->port_id, ret);
 exit:
-	free(mp_rep.msgs);
+	mlx5_free(mp_rep.msgs);
 	return ret;
 }
 
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index 2179a83..af2863e 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -9,6 +9,7 @@
 #include "mlx5_prm.h"
 #include "mlx5_devx_cmds.h"
 #include "mlx5_common_utils.h"
+#include "mlx5_malloc.h"
 
 
 /**
@@ -28,7 +29,8 @@
 struct mlx5_devx_obj *
 mlx5_devx_cmd_flow_counter_alloc(void *ctx, uint32_t bulk_n_128)
 {
-	struct mlx5_devx_obj *dcs = rte_zmalloc("dcs", sizeof(*dcs), 0);
+	struct mlx5_devx_obj *dcs = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*dcs),
+						0, SOCKET_ID_ANY);
 	uint32_t in[MLX5_ST_SZ_DW(alloc_flow_counter_in)]   = {0};
 	uint32_t out[MLX5_ST_SZ_DW(alloc_flow_counter_out)] = {0};
 
@@ -44,7 +46,7 @@ struct mlx5_devx_obj *
 	if (!dcs->obj) {
 		DRV_LOG(ERR, "Can't allocate counters - error %d", errno);
 		rte_errno = errno;
-		rte_free(dcs);
+		mlx5_free(dcs);
 		return NULL;
 	}
 	dcs->id = MLX5_GET(alloc_flow_counter_out, out, flow_counter_id);
@@ -149,7 +151,8 @@ struct mlx5_devx_obj *
 	uint32_t in[in_size_dw];
 	uint32_t out[MLX5_ST_SZ_DW(create_mkey_out)] = {0};
 	void *mkc;
-	struct mlx5_devx_obj *mkey = rte_zmalloc("mkey", sizeof(*mkey), 0);
+	struct mlx5_devx_obj *mkey = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*mkey),
+						 0, SOCKET_ID_ANY);
 	size_t pgsize;
 	uint32_t translation_size;
 
@@ -208,7 +211,7 @@ struct mlx5_devx_obj *
 		DRV_LOG(ERR, "Can't create %sdirect mkey - error %d\n",
 			klm_num ? "an in" : "a ", errno);
 		rte_errno = errno;
-		rte_free(mkey);
+		mlx5_free(mkey);
 		return NULL;
 	}
 	mkey->id = MLX5_GET(create_mkey_out, out, mkey_index);
@@ -260,7 +263,7 @@ struct mlx5_devx_obj *
 	if (!obj)
 		return 0;
 	ret =  mlx5_glue->devx_obj_destroy(obj->obj);
-	rte_free(obj);
+	mlx5_free(obj);
 	return ret;
 }
 
@@ -671,7 +674,7 @@ struct mlx5_devx_obj *
 	struct mlx5_devx_wq_attr *wq_attr;
 	struct mlx5_devx_obj *rq = NULL;
 
-	rq = rte_calloc_socket(__func__, 1, sizeof(*rq), 0, socket);
+	rq = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rq), 0, socket);
 	if (!rq) {
 		DRV_LOG(ERR, "Failed to allocate RQ data");
 		rte_errno = ENOMEM;
@@ -699,7 +702,7 @@ struct mlx5_devx_obj *
 	if (!rq->obj) {
 		DRV_LOG(ERR, "Failed to create RQ using DevX");
 		rte_errno = errno;
-		rte_free(rq);
+		mlx5_free(rq);
 		return NULL;
 	}
 	rq->id = MLX5_GET(create_rq_out, out, rqn);
@@ -776,7 +779,7 @@ struct mlx5_devx_obj *
 	void *tir_ctx, *outer, *inner, *rss_key;
 	struct mlx5_devx_obj *tir = NULL;
 
-	tir = rte_calloc(__func__, 1, sizeof(*tir), 0);
+	tir = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*tir), 0, SOCKET_ID_ANY);
 	if (!tir) {
 		DRV_LOG(ERR, "Failed to allocate TIR data");
 		rte_errno = ENOMEM;
@@ -818,7 +821,7 @@ struct mlx5_devx_obj *
 	if (!tir->obj) {
 		DRV_LOG(ERR, "Failed to create TIR using DevX");
 		rte_errno = errno;
-		rte_free(tir);
+		mlx5_free(tir);
 		return NULL;
 	}
 	tir->id = MLX5_GET(create_tir_out, out, tirn);
@@ -848,17 +851,17 @@ struct mlx5_devx_obj *
 	struct mlx5_devx_obj *rqt = NULL;
 	int i;
 
-	in = rte_calloc(__func__, 1, inlen, 0);
+	in = mlx5_malloc(MLX5_MEM_ZERO, inlen, 0, SOCKET_ID_ANY);
 	if (!in) {
 		DRV_LOG(ERR, "Failed to allocate RQT IN data");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
-	rqt = rte_calloc(__func__, 1, sizeof(*rqt), 0);
+	rqt = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rqt), 0, SOCKET_ID_ANY);
 	if (!rqt) {
 		DRV_LOG(ERR, "Failed to allocate RQT data");
 		rte_errno = ENOMEM;
-		rte_free(in);
+		mlx5_free(in);
 		return NULL;
 	}
 	MLX5_SET(create_rqt_in, in, opcode, MLX5_CMD_OP_CREATE_RQT);
@@ -869,11 +872,11 @@ struct mlx5_devx_obj *
 	for (i = 0; i < rqt_attr->rqt_actual_size; i++)
 		MLX5_SET(rqtc, rqt_ctx, rq_num[i], rqt_attr->rq_list[i]);
 	rqt->obj = mlx5_glue->devx_obj_create(ctx, in, inlen, out, sizeof(out));
-	rte_free(in);
+	mlx5_free(in);
 	if (!rqt->obj) {
 		DRV_LOG(ERR, "Failed to create RQT using DevX");
 		rte_errno = errno;
-		rte_free(rqt);
+		mlx5_free(rqt);
 		return NULL;
 	}
 	rqt->id = MLX5_GET(create_rqt_out, out, rqtn);
@@ -898,7 +901,7 @@ struct mlx5_devx_obj *
 	uint32_t inlen = MLX5_ST_SZ_BYTES(modify_rqt_in) +
 			 rqt_attr->rqt_actual_size * sizeof(uint32_t);
 	uint32_t out[MLX5_ST_SZ_DW(modify_rqt_out)] = {0};
-	uint32_t *in = rte_calloc(__func__, 1, inlen, 0);
+	uint32_t *in = mlx5_malloc(MLX5_MEM_ZERO, inlen, 0, SOCKET_ID_ANY);
 	void *rqt_ctx;
 	int i;
 	int ret;
@@ -918,7 +921,7 @@ struct mlx5_devx_obj *
 	for (i = 0; i < rqt_attr->rqt_actual_size; i++)
 		MLX5_SET(rqtc, rqt_ctx, rq_num[i], rqt_attr->rq_list[i]);
 	ret = mlx5_glue->devx_obj_modify(rqt->obj, in, inlen, out, sizeof(out));
-	rte_free(in);
+	mlx5_free(in);
 	if (ret) {
 		DRV_LOG(ERR, "Failed to modify RQT using DevX.");
 		rte_errno = errno;
@@ -951,7 +954,7 @@ struct mlx5_devx_obj *
 	struct mlx5_devx_wq_attr *wq_attr;
 	struct mlx5_devx_obj *sq = NULL;
 
-	sq = rte_calloc(__func__, 1, sizeof(*sq), 0);
+	sq = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*sq), 0, SOCKET_ID_ANY);
 	if (!sq) {
 		DRV_LOG(ERR, "Failed to allocate SQ data");
 		rte_errno = ENOMEM;
@@ -985,7 +988,7 @@ struct mlx5_devx_obj *
 	if (!sq->obj) {
 		DRV_LOG(ERR, "Failed to create SQ using DevX");
 		rte_errno = errno;
-		rte_free(sq);
+		mlx5_free(sq);
 		return NULL;
 	}
 	sq->id = MLX5_GET(create_sq_out, out, sqn);
@@ -1049,7 +1052,7 @@ struct mlx5_devx_obj *
 	struct mlx5_devx_obj *tis = NULL;
 	void *tis_ctx;
 
-	tis = rte_calloc(__func__, 1, sizeof(*tis), 0);
+	tis = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*tis), 0, SOCKET_ID_ANY);
 	if (!tis) {
 		DRV_LOG(ERR, "Failed to allocate TIS object");
 		rte_errno = ENOMEM;
@@ -1069,7 +1072,7 @@ struct mlx5_devx_obj *
 	if (!tis->obj) {
 		DRV_LOG(ERR, "Failed to create TIS using DevX");
 		rte_errno = errno;
-		rte_free(tis);
+		mlx5_free(tis);
 		return NULL;
 	}
 	tis->id = MLX5_GET(create_tis_out, out, tisn);
@@ -1091,7 +1094,7 @@ struct mlx5_devx_obj *
 	uint32_t out[MLX5_ST_SZ_DW(alloc_transport_domain_out)] = {0};
 	struct mlx5_devx_obj *td = NULL;
 
-	td = rte_calloc(__func__, 1, sizeof(*td), 0);
+	td = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*td), 0, SOCKET_ID_ANY);
 	if (!td) {
 		DRV_LOG(ERR, "Failed to allocate TD object");
 		rte_errno = ENOMEM;
@@ -1104,7 +1107,7 @@ struct mlx5_devx_obj *
 	if (!td->obj) {
 		DRV_LOG(ERR, "Failed to create TIS using DevX");
 		rte_errno = errno;
-		rte_free(td);
+		mlx5_free(td);
 		return NULL;
 	}
 	td->id = MLX5_GET(alloc_transport_domain_out, out,
@@ -1168,8 +1171,9 @@ struct mlx5_devx_obj *
 {
 	uint32_t in[MLX5_ST_SZ_DW(create_cq_in)] = {0};
 	uint32_t out[MLX5_ST_SZ_DW(create_cq_out)] = {0};
-	struct mlx5_devx_obj *cq_obj = rte_zmalloc(__func__, sizeof(*cq_obj),
-						   0);
+	struct mlx5_devx_obj *cq_obj = mlx5_malloc(MLX5_MEM_ZERO,
+						   sizeof(*cq_obj),
+						   0, SOCKET_ID_ANY);
 	void *cqctx = MLX5_ADDR_OF(create_cq_in, in, cq_context);
 
 	if (!cq_obj) {
@@ -1203,7 +1207,7 @@ struct mlx5_devx_obj *
 	if (!cq_obj->obj) {
 		rte_errno = errno;
 		DRV_LOG(ERR, "Failed to create CQ using DevX errno=%d.", errno);
-		rte_free(cq_obj);
+		mlx5_free(cq_obj);
 		return NULL;
 	}
 	cq_obj->id = MLX5_GET(create_cq_out, out, cqn);
@@ -1227,8 +1231,9 @@ struct mlx5_devx_obj *
 {
 	uint32_t in[MLX5_ST_SZ_DW(create_virtq_in)] = {0};
 	uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0};
-	struct mlx5_devx_obj *virtq_obj = rte_zmalloc(__func__,
-						     sizeof(*virtq_obj), 0);
+	struct mlx5_devx_obj *virtq_obj = mlx5_malloc(MLX5_MEM_ZERO,
+						     sizeof(*virtq_obj),
+						     0, SOCKET_ID_ANY);
 	void *virtq = MLX5_ADDR_OF(create_virtq_in, in, virtq);
 	void *hdr = MLX5_ADDR_OF(create_virtq_in, in, hdr);
 	void *virtctx = MLX5_ADDR_OF(virtio_net_q, virtq, virtio_q_context);
@@ -1276,7 +1281,7 @@ struct mlx5_devx_obj *
 	if (!virtq_obj->obj) {
 		rte_errno = errno;
 		DRV_LOG(ERR, "Failed to create VIRTQ Obj using DevX.");
-		rte_free(virtq_obj);
+		mlx5_free(virtq_obj);
 		return NULL;
 	}
 	virtq_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id);
@@ -1398,8 +1403,9 @@ struct mlx5_devx_obj *
 {
 	uint32_t in[MLX5_ST_SZ_DW(create_qp_in)] = {0};
 	uint32_t out[MLX5_ST_SZ_DW(create_qp_out)] = {0};
-	struct mlx5_devx_obj *qp_obj = rte_zmalloc(__func__, sizeof(*qp_obj),
-						   0);
+	struct mlx5_devx_obj *qp_obj = mlx5_malloc(MLX5_MEM_ZERO,
+						   sizeof(*qp_obj),
+						   0, SOCKET_ID_ANY);
 	void *qpc = MLX5_ADDR_OF(create_qp_in, in, qpc);
 
 	if (!qp_obj) {
@@ -1454,7 +1460,7 @@ struct mlx5_devx_obj *
 	if (!qp_obj->obj) {
 		rte_errno = errno;
 		DRV_LOG(ERR, "Failed to create QP Obj using DevX.");
-		rte_free(qp_obj);
+		mlx5_free(qp_obj);
 		return NULL;
 	}
 	qp_obj->id = MLX5_GET(create_qp_out, out, qpn);
@@ -1550,8 +1556,9 @@ struct mlx5_devx_obj *
 {
 	uint32_t in[MLX5_ST_SZ_DW(create_virtio_q_counters_in)] = {0};
 	uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0};
-	struct mlx5_devx_obj *couners_obj = rte_zmalloc(__func__,
-						       sizeof(*couners_obj), 0);
+	struct mlx5_devx_obj *couners_obj = mlx5_malloc(MLX5_MEM_ZERO,
+						       sizeof(*couners_obj), 0,
+						       SOCKET_ID_ANY);
 	void *hdr = MLX5_ADDR_OF(create_virtio_q_counters_in, in, hdr);
 
 	if (!couners_obj) {
@@ -1569,7 +1576,7 @@ struct mlx5_devx_obj *
 		rte_errno = errno;
 		DRV_LOG(ERR, "Failed to create virtio queue counters Obj using"
 			" DevX.");
-		rte_free(couners_obj);
+		mlx5_free(couners_obj);
 		return NULL;
 	}
 	couners_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id);
