Added checks to memory allocation failure when using asprintf.

Signed-off-by: Dotan Barak <[EMAIL PROTECTED]>
---

Index: gen2_devel_user/src/userspace/libibcm/src/cm.c
===================================================================
--- gen2_devel_user.orig/src/userspace/libibcm/src/cm.c 2007-01-15 
17:02:21.000000000 +0200
+++ gen2_devel_user/src/userspace/libibcm/src/cm.c      2007-01-16 
10:12:28.000000000 +0200
@@ -150,8 +150,9 @@ struct ib_cm_device* ib_cm_open_device(s
 
        dev->device_context = device_context;
 
-       asprintf(&dev_path, "/dev/infiniband/ucm%s",
-                device_context->device->dev_name + sizeof("uverbs") - 1);
+       if (asprintf(&dev_path, "/dev/infiniband/ucm%s",
+                device_context->device->dev_name + sizeof("uverbs") - 1) < 0)
+               goto err2;
 
        dev->fd = open(dev_path, O_RDWR);
        if (dev->fd < 0) {
@@ -164,6 +165,7 @@ struct ib_cm_device* ib_cm_open_device(s
 
 err:
        free(dev_path);
+err2:
        free(dev);
        return NULL;
 }



_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to