nvme/rdma: Fix rdma allocation return unique pointer

Allocate memory with zero number or size, maybe return a unique
pointer rather than NULL. Add a check before common allocation APIs.

Change-Id: I83e07cab5145035e705bc32364652be90f238633
Signed-off-by: Mao Jiang <maox.jiang@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5809
Reviewed-by: GangCao <gang.cao@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Mao Jiang 2021-01-07 17:17:41 +08:00 committed by Tomasz Zawadzki
parent 731cd47e66
commit 6fd1459493

View File

@ -304,6 +304,10 @@ struct nvme_rdma_qpair *nvme_rdma_poll_group_get_qpair_by_id(struct nvme_rdma_po
static inline void *
nvme_rdma_calloc(size_t nmemb, size_t size)
{
if (!nmemb || !size) {
return NULL;
}
if (!g_nvme_hooks.get_rkey) {
return calloc(nmemb, size);
} else {