From 37dd2ca645c6b04a24ea0c96cdab28a45ac40952 Mon Sep 17 00:00:00 2001
From: Weronika Lewandowska <weronika.lewandowska@intel.com>
Date: Tue, 16 Jun 2020 14:48:38 +0200
Subject: [PATCH] pmem2: fix get alignment funcs

---
 src/common/file_posix.c               |  1 +
 src/libpmem2/region_namespace_ndctl.c | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/common/file_posix.c b/src/common/file_posix.c
index acacf9073..f887244ef 100644
--- a/src/common/file_posix.c
+++ b/src/common/file_posix.c
@@ -203,6 +203,7 @@ device_dax_alignment(const char *path)
 	}
 
 end:
+	pmem2_source_delete(&src);
 	os_close(fd);
 	return size;
 }
diff --git a/src/libpmem2/region_namespace_ndctl.c b/src/libpmem2/region_namespace_ndctl.c
index d503c62f5..1383796a9 100644
--- a/src/libpmem2/region_namespace_ndctl.c
+++ b/src/libpmem2/region_namespace_ndctl.c
@@ -140,8 +140,8 @@ pmem2_region_namespace(struct ndctl_ctx *ctx,
 	struct ndctl_region *region;
 	struct ndctl_namespace *ndns;
 
-	ASSERTne(pregion, NULL);
-	*pregion = NULL;
+	if (pregion)
+		*pregion = NULL;
 
 	if (pndns)
 		*pndns = NULL;
@@ -177,7 +177,8 @@ pmem2_region_namespace(struct ndctl_ctx *ctx,
 					return ret;
 
 				if (ret == 0) {
-					*pregion = region;
+					if (pregion)
+						*pregion = region;
 					if (pndns)
 						*pndns = ndns;
 
@@ -204,7 +205,8 @@ pmem2_region_namespace(struct ndctl_ctx *ctx,
 				return ret;
 
 			if (ret == 0) {
-				*pregion = region;
+				if (pregion)
+					*pregion = region;
 				if (pndns)
 					*pndns = ndns;
 
-- 
GitLab