]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Handle asprintf memory allocation failures
authorDotan Barak <dotanb@mellanox.co.il>
Tue, 16 Jan 2007 20:21:25 +0000 (12:21 -0800)
committerRoland Dreier <rolandd@cisco.com>
Tue, 16 Jan 2007 20:21:25 +0000 (12:21 -0800)
Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
src/device.c
src/sysfs.c

index 3bfbca69b264ac3ce50ea1d7f2194d64b0338bd7..f7ef224f4d916b183f2dbe1c4965e92b08484283 100644 (file)
@@ -111,7 +111,8 @@ struct ibv_context *ibv_open_device(struct ibv_device *device)
        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
index e274c03dfc7c3f2472ef3afa469944bda14cb9d0..392a67580cc4b321d9a758d6c0a88904ea136253 100644 (file)
@@ -82,7 +82,8 @@ int ibv_read_sysfs_file(const char *dir, const char *file,
        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) {