@@ -747,12 +747,18 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
} else if (dax_region) {
struct daxctl_dev *dev;
+ /*
+ * We can only find/list these device-dax
+ * details when the instance is enabled.
+ */
dev = daxctl_dev_get_first(dax_region);
- name = daxctl_dev_get_devname(dev);
- jobj = json_object_new_string(name);
- if (!jobj)
- goto err;
- json_object_object_add(jndns, "chardev", jobj);
+ if (dev) {
+ name = daxctl_dev_get_devname(dev);
+ jobj = json_object_new_string(name);
+ if (!jobj)
+ goto err;
+ json_object_object_add(jndns, "chardev", jobj);
+ }
}
} else if (ndctl_namespace_get_type(ndns) != ND_DEVICE_NAMESPACE_IO) {
ndctl_namespace_get_uuid(ndns, uuid);
The following crash results from running 'ndctl list -i' on an inactive namespace that is claimed for device-dax operation. Program received signal SIGSEGV, Segmentation fault. daxctl_dev_get_devname (dev=0x0) at libdaxctl.c:566 566 return devpath_to_devname(dev->dev_path); (gdb) bt #0 daxctl_dev_get_devname (dev=0x0) at libdaxctl.c:566 #1 0x0000555555563b39 in util_namespace_to_json at ../util/json.c:751 By definition the 'chardev' attribute for a device-dax instance can not be found if the device-dax instance is disabled, because enabling the namespace creates the child character device(s). Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- util/json.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)