]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
librdmacm: Fail ucma_init if ibv_get_device_list is empty
authorYann Droneaud <ydroneaud@opteya.com>
Fri, 27 May 2011 17:59:50 +0000 (10:59 -0700)
committerSean Hefty <sean.hefty@intel.com>
Fri, 27 May 2011 17:59:50 +0000 (10:59 -0700)
From the 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.

The librdmacm handles the failure case, but not the case where no
devices are found.  Handle that case as well.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/cma.c

index 846b5ce4ec239f4a71e9afb76347e334308339c6..d6cb626d5ba7bd24832fa0c30df25e4748db44df 100755 (executable)
--- a/src/cma.c
+++ b/src/cma.c
@@ -253,6 +253,12 @@ int ucma_init(void)
                goto err1;
        }
 
+       if (!dev_cnt) {
+               printf("CMA: no RDMA devices found\n");
+               ret = ERR(ENODEV);
+               goto err2;
+       }
+               
        cma_dev_array = malloc(sizeof *cma_dev * dev_cnt);
        if (!cma_dev_array) {
                ret = ERR(ENOMEM);