Message ID | 157488678518.2821503.2969182209770415299.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive) |
---|---|
State | Accepted |
Commit | b672780fd78734047f236475b627ce981ff09132 |
Headers | show |
Series | [daxctl] daxctl/list: Avoid memory operations without resource data | expand |
diff --git a/util/json.c b/util/json.c index 0abaf3a5b9c2..6745bcc19058 100644 --- a/util/json.c +++ b/util/json.c @@ -306,7 +306,7 @@ struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev, if (jobj) json_object_object_add(jdev, "mode", jobj); - if (mem) { + if (mem && daxctl_dev_get_resource(dev) != 0) { movable = daxctl_memory_is_movable(mem); if (movable == 1) jobj = json_object_new_boolean(true);
Resource data is restricted to root-only, and "daxctl list" is likely to be run by non-root. Skip listing memory-object details when the resource is not available. Otherwise, "daxctl list" from non-root emits: libdaxctl: memblock_in_dev: dax1.0: Unable to determine resource Reported-by: Michal Biesek <michal.biesek@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- util/json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)