Message ID | 1306518158-7770-1-git-send-email-ydroneaud@opteya.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
diff --git a/src/cma.c b/src/cma.c index 846b5ce..c8d9b9f 100755 --- a/src/cma.c +++ b/src/cma.c @@ -246,6 +246,7 @@ int ucma_init(void) if (ret) goto err1; + dev_cnt = 0; dev_list = ibv_get_device_list(&dev_cnt); if (!dev_list) { printf("CMA: unable to get RDMA device list\n"); @@ -253,6 +254,12 @@ int ucma_init(void) goto err1; } + if (!dev_cnt) { + printf("CMA: unable to get RDMA device list\n"); + ret = ERR(ENODEV); + goto err2; + } + cma_dev_array = malloc(sizeof *cma_dev * dev_cnt); if (!cma_dev_array) { ret = ERR(ENOMEM);
As stated in ibv_get_device_list() man page: ibv_get_device_list() returns the array of available RDMA devices, or sets errno and returns NULL if the request fails. If no devices are found then num_devices is set to 0, and non-NULL is returned. Signed-off-by: Yann Droneaud <ydroneaud@opteya.com> --- src/cma.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)