From patchwork Fri May 27 17:42:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Droneaud X-Patchwork-Id: 825092 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4RHpUSr024140 for ; Fri, 27 May 2011 17:51:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751472Ab1E0Rv3 (ORCPT ); Fri, 27 May 2011 13:51:29 -0400 Received: from smtp12.smtpout.orange.fr ([80.12.242.134]:26913 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751080Ab1E0Rv3 (ORCPT ); Fri, 27 May 2011 13:51:29 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 27 May 2011 17:51:31 +0000 (UTC) X-Greylist: delayed 476 seconds by postgrey-1.27 at vger.kernel.org; Fri, 27 May 2011 13:51:28 EDT Received: from deela.quest-ce.net ([80.12.82.111]) by mwinf5d23 with ME id ohjT1g0032Q6X8003hjTwp; Fri, 27 May 2011 19:43:29 +0200 Received: from deela.quest-ce.net (deela.quest-ce.net [127.0.0.1]) by deela.quest-ce.net (8.14.5/8.14.4) with ESMTP id p4RHh03w007808; Fri, 27 May 2011 19:43:18 +0200 Received: (from ydroneaud@localhost) by deela.quest-ce.net (8.14.5/8.14.5/Submit) id p4RHgwm5007807; Fri, 27 May 2011 19:42:58 +0200 From: Yann Droneaud To: Sean Hefty Cc: Yann Droneaud , Roland Dreier , Animesh K Trivedi1 , linux-rdma@vger.kernel.org, Bernard Metzler Subject: [PATCH:rdmacm] ucma_init: fail if ibv_get_device_list() returns empty list Date: Fri, 27 May 2011 19:42:38 +0200 Message-Id: <1306518158-7770-1-git-send-email-ydroneaud@opteya.com> X-Mailer: git-send-email 1.7.5.2 In-Reply-To: <1306517515.1835.15.camel@deela.quest-ce.net> References: <1306493434.1835.4.camel@deela.quest-ce.net> <1306515973.1835.11.camel@deela.quest-ce.net> <1306517515.1835.15.camel@deela.quest-ce.net> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org 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 --- 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);