diff mbox

[PATCH:rdmacm] ucma_init: fail if ibv_get_device_list() returns empty list

Message ID 1828884A29C6694DAF28B7E6B8A823730119BA@ORSMSX101.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hefty, Sean May 27, 2011, 6:01 p.m. UTC
>   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.

Thanks.  I think the following fixes the same issue.  If this looks okay to you, I'll will commit.

Signed-off-by: Sean Hefty <sean.hefty@intel.com

---

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Yann Droneaud May 27, 2011, 9:12 p.m. UTC | #1
Hi, 

Le vendredi 27 mai 2011 à 18:01 +0000, Hefty, Sean a écrit :
> >   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.
> 
> Thanks.  I think the following fixes the same issue.  If this looks okay to you, I'll will commit.
> 

You're not handling the error case when ibv_get_device_list() returns
NULL.
We need two different error path: one for NULL and one for empty list.
In the latter case, the list must be freed.

Regards.
diff mbox

Patch

diff --git a/src/cma.c b/src/cma.c
index 846b5ce..86cb455 100755
--- a/src/cma.c
+++ b/src/cma.c
@@ -247,7 +247,7 @@  int ucma_init(void)
                goto err1;

        dev_list = ibv_get_device_list(&dev_cnt);
-       if (!dev_list) {
+       if (!dev_cnt) {
                printf("CMA: unable to get RDMA device list\n");
                ret = ERR(ENODEV);
                goto err1;