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 <[email protected]> --- src/cma.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) 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); -- 1.7.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
