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:
parent
731cd47e66
commit
6fd1459493
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user