Similar to commit 59a9803454ee "util_namespace_to_json: fix potential
null pointer dereference" check that we actually get a btt instance when
the namespace is detected to be in "safe" mode.

Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
---
 ndctl/util/json.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/ndctl/util/json.c b/ndctl/util/json.c
index 6b74c240a3f5..82e677c2c7a7 100644
--- a/ndctl/util/json.c
+++ b/ndctl/util/json.c
@@ -179,6 +179,8 @@ struct json_object *util_namespace_to_json(struct 
ndctl_namespace *ndns,
                jobj = json_object_new_string("dax");
                break;
        case NDCTL_NS_MODE_SAFE:
+               if (!btt)
+                       goto err;
                jobj = json_object_new_string("sector");
                size = ndctl_btt_get_size(btt);
                break;

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

Reply via email to