Message ID | 20160623195950.30968-2-jmoyer@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Jun 23, 2016 at 12:59 PM, Jeff Moyer <jmoyer@redhat.com> wrote: > Coverity pointed out that "dax" could be NULL, and it goes unchecked. > > Signed-off-by: Jeff Moyer <jmoyer@redhat.com> > --- > ndctl/util/json.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/ndctl/util/json.c b/ndctl/util/json.c > index d144039..92e50fa 100644 > --- a/ndctl/util/json.c > +++ b/ndctl/util/json.c > @@ -133,6 +133,8 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns) > jobj = json_object_new_string("memory"); > break; > case NDCTL_NS_MODE_DAX: > + if (!dax) > + goto err; > size = ndctl_dax_get_size(dax); > jobj = json_object_new_string("dax"); > break; The other patches look good, this one points out a problem with ndctl_namespace_get_mode() which should be using a cached value rather reading it from sysfs directly. When we snapshot it with a cached value it becomes impossible to have ndctl_namespace_get_mode() == NDCTL_NS_MODE_DAX and ndctl_namespace_get_dax() == NULL.
diff --git a/ndctl/util/json.c b/ndctl/util/json.c index d144039..92e50fa 100644 --- a/ndctl/util/json.c +++ b/ndctl/util/json.c @@ -133,6 +133,8 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns) jobj = json_object_new_string("memory"); break; case NDCTL_NS_MODE_DAX: + if (!dax) + goto err; size = ndctl_dax_get_size(dax); jobj = json_object_new_string("dax"); break;
Coverity pointed out that "dax" could be NULL, and it goes unchecked. Signed-off-by: Jeff Moyer <jmoyer@redhat.com> --- ndctl/util/json.c | 2 ++ 1 file changed, 2 insertions(+)