Added checks to memory allocation failure when using asprintf.
Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
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) {
err:
free(dev_path);
+err2:
free(dev);
return NULL;
}