If ->region_path is not set, do not attempt to take its length.

Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
---
 daxctl/lib/libdaxctl.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index ecdb99640115..8f1b88e06ac6 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -217,14 +217,19 @@ DAXCTL_EXPORT struct daxctl_region 
*daxctl_new_region(struct daxctl_ctx *ctx,
        region->id = id;
        region->refcount = 1;
        uuid_copy(region->uuid, uuid);
+
        region->region_path = strdup(path);
+       if (!region->region_path) {
+               free(region);
+               return NULL;
+       }
+
        list_head_init(&region->devices);
        region->buf_len = strlen(region->region_path) + REGION_BUF_SIZE;
        region->region_buf = calloc(1, region->buf_len);
-
-       if (!region->region_path || !region->region_buf) {
+       if (!region->region_buf) {
                daxctl_region_unref(region);
-               region = NULL;
+               return NULL;
        }
 
        dbg(ctx, "%s: %s\n", __func__, daxctl_region_get_devname(region));

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to