[openib-general] avoid segv in libibverbs/examples

Pete Wyckoff pw at osc.edu
Fri Aug 12 07:42:22 PDT 2005


Against latest svn, in gen2/trunk/userspace/libibverbs/examples.
These tools segv when the sysfs lookup doesn't find an IB card.

		-- Pete

Index: asyncwatch.c
===================================================================
--- asyncwatch.c	(revision 3072)
+++ asyncwatch.c	(working copy)
@@ -56,6 +56,8 @@
 	struct ibv_async_event event;
 
 	dev_list = ibv_get_devices();
+	if (!dev_list)
+		return 1;
 
 	dlist_start(dev_list);
 	ib_dev = dlist_next(dev_list);
Index: rc_pingpong.c
===================================================================
--- rc_pingpong.c	(revision 3072)
+++ rc_pingpong.c	(working copy)
@@ -524,6 +524,8 @@
 	page_size = sysconf(_SC_PAGESIZE);
 
 	dev_list = ibv_get_devices();
+	if (!dev_list)
+		return 1;
 
 	dlist_start(dev_list);
 	if (!ib_devname) {
Index: srq_pingpong.c
===================================================================
--- srq_pingpong.c	(revision 3072)
+++ srq_pingpong.c	(working copy)
@@ -593,6 +593,8 @@
 	page_size = sysconf(_SC_PAGESIZE);
 
 	dev_list = ibv_get_devices();
+	if (!dev_list)
+		return 1;
 
 	dlist_start(dev_list);
 	if (!ib_devname) {
Index: uc_pingpong.c
===================================================================
--- uc_pingpong.c	(revision 3072)
+++ uc_pingpong.c	(working copy)
@@ -516,6 +516,8 @@
 	page_size = sysconf(_SC_PAGESIZE);
 
 	dev_list = ibv_get_devices();
+	if (!dev_list)
+		return 1;
 
 	dlist_start(dev_list);
 	if (!ib_devname) {
Index: ud_pingpong.c
===================================================================
--- ud_pingpong.c	(revision 3072)
+++ ud_pingpong.c	(working copy)
@@ -520,6 +520,8 @@
 	page_size = sysconf(_SC_PAGESIZE);
 
 	dev_list = ibv_get_devices();
+	if (!dev_list)
+		return 1;
 
 	dlist_start(dev_list);
 	if (!ib_devname) {
Index: device_list.c
===================================================================
--- device_list.c	(revision 3072)
+++ device_list.c	(working copy)
@@ -55,6 +55,8 @@
 	struct ibv_device *ib_dev;
 
 	dev_list = ibv_get_devices();
+	if (!dev_list)
+		return 1;
 
 	printf("    %-16s\t   node GUID\n", "device");
 	printf("    %-16s\t----------------\n", "------");
Index: devinfo.c
===================================================================
--- devinfo.c	(revision 3072)
+++ devinfo.c	(working copy)
@@ -58,6 +58,8 @@
         int i;
 
 	dev_list = ibv_get_devices();
+	if (!dev_list)
+		return 1;
 
 	dlist_start(dev_list);
 	ib_dev = dlist_next(dev_list);



More information about the general mailing list