Added checks to memory allocation failure when using asprintf.
Signed-off-by: Dotan Barak <[EMAIL PROTECTED]>
---
Index: gen2_devel_user/src/userspace/libibverbs/src/device.c
===================================================================
--- gen2_devel_user.orig/src/userspace/libibverbs/src/device.c 2007-01-15
17:02:23.000000000 +0200
+++ gen2_devel_user/src/userspace/libibverbs/src/device.c 2007-01-16
09:48:19.000000000 +0200
@@ -111,7 +111,8 @@ struct ibv_context *ibv_open_device(stru
int cmd_fd;
struct ibv_context *context;
- asprintf(&devpath, "/dev/infiniband/%s", device->dev_name);
+ if (asprintf(&devpath, "/dev/infiniband/%s", device->dev_name) < 0)
+ return NULL;
/*
* We'll only be doing writes, but we need O_RDWR in case the
Index: gen2_devel_user/src/userspace/libibverbs/src/sysfs.c
===================================================================
--- gen2_devel_user.orig/src/userspace/libibverbs/src/sysfs.c 2007-01-15
17:02:23.000000000 +0200
+++ gen2_devel_user/src/userspace/libibverbs/src/sysfs.c 2007-01-16
09:48:44.000000000 +0200
@@ -82,7 +82,8 @@ int ibv_read_sysfs_file(const char *dir,
int fd;
int len;
- asprintf(&path, "%s/%s", dir, file);
+ if (asprintf(&path, "%s/%s", dir, file) < 0)
+ return -1;
fd = open(path, O_RDONLY);
if (fd < 0) {
_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general
To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general