All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: Jeff Moyer <jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: linux-nvdimm <linux-nvdimm-y27Ovi1pjclAfugRpC6u6w@public.gmane.org>
Subject: Re: [PATCH 1/3] util_namespace_to_json: fix potential null pointer dereference
Date: Thu, 23 Jun 2016 13:12:49 -0700	[thread overview]
Message-ID: <CAPcyv4i9gPufyzCLcZi64Mh=1W-zv44D3vrEVqkOutw=JtXssA@mail.gmail.com> (raw)
In-Reply-To: <20160623195950.30968-2-jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Thu, Jun 23, 2016 at 12:59 PM, Jeff Moyer <jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> Coverity pointed out that "dax" could be NULL, and it goes unchecked.
>
> Signed-off-by: Jeff Moyer <jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  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.

  parent reply	other threads:[~2016-06-23 20:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-23 19:59 [PATCH 0/3] Misc. ndctl fixes Jeff Moyer
     [not found] ` <20160623195950.30968-1-jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-06-23 19:59   ` [PATCH 1/3] util_namespace_to_json: fix potential null pointer dereference Jeff Moyer
     [not found]     ` <20160623195950.30968-2-jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-06-23 20:12       ` Dan Williams [this message]
2016-06-23 19:59   ` [PATCH 2/3] daxctl_region_unref: fix a " Jeff Moyer
2016-06-23 19:59   ` [PATCH 3/3] validate_namespace_options: fix bogus test Jeff Moyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPcyv4i9gPufyzCLcZi64Mh=1W-zv44D3vrEVqkOutw=JtXssA@mail.gmail.com' \
    --to=dan.j.williams-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-nvdimm-y27Ovi1pjclAfugRpC6u6w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.