[openib-general] libibverbs regression
Steve Wise
swise at opengridcomputing.com
Fri Jan 19 08:20:29 PST 2007
Roland,
I think this breaks things. The man page for asprintf() sez it returns
the number of bytes upon success. The patch below assumes non-zero is a
failure. So all requests to get the sysfs path will fail.
Steve.
commit dd3d43d89e398f23c4824d26f2698446ff2d120f
Author: Dotan Barak <dotanb at mellanox.co.il>
Date: Tue Jan 16 12:21:25 2007 -0800
Handle asprintf memory allocation failures
Signed-off-by: Dotan Barak <dotanb at mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd at cisco.com>
diff --git a/src/device.c b/src/device.c
index 3bfbca6..f7ef224 100644
--- a/src/device.c
+++ b/src/device.c
@@ -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))
+ return NULL;
/*
* We'll only be doing writes, but we need O_RDWR in case the
diff --git a/src/sysfs.c b/src/sysfs.c
index e274c03..392a675 100644
--- a/src/sysfs.c
+++ b/src/sysfs.c
@@ -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))
+ return -1;
fd = open(path, O_RDONLY);
if (fd < 0) {
More information about the general
mailing list