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 <[EMAIL PROTECTED]>
Date:   Tue Jan 16 12:21:25 2007 -0800

    Handle asprintf memory allocation failures
    
    Signed-off-by: Dotan Barak <[EMAIL PROTECTED]>
    Signed-off-by: Roland Dreier <[EMAIL PROTECTED]>

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) {





_______________________________________________
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