[openib-general] [libibcm] [PATCH] Added checks to memory allocation failure when using asprintf
Dotan Barak
dotanb at dev.mellanox.co.il
Tue Jan 16 01:51:33 PST 2007
Added checks to memory allocation failure when using asprintf.
Signed-off-by: Dotan Barak <dotanb at mellanox.co.il>
---
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;
}
More information about the general
mailing list