All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Moyer <jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Cc: linux-nvdimm-y27Ovi1pjclAfugRpC6u6w@public.gmane.org
Subject: [PATCH 2/3] daxctl_region_unref: fix a potential null pointer dereference
Date: Thu, 23 Jun 2016 15:59:49 -0400	[thread overview]
Message-ID: <20160623195950.30968-3-jmoyer@redhat.com> (raw)
In-Reply-To: <20160623195950.30968-1-jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Move the assignment of ctx to after the NULL check.

Signed-off-by: Jeff Moyer <jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 daxctl/lib/libdaxctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index a8ad58d..9d71a29 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -181,7 +181,7 @@ static void free_dev(struct daxctl_dev *dev, struct list_head *head)
 
 DAXCTL_EXPORT void daxctl_region_unref(struct daxctl_region *region)
 {
-	struct daxctl_ctx *ctx = region->ctx;
+	struct daxctl_ctx *ctx;
 	struct daxctl_dev *dev, *_d;
 
 	if (!region)
@@ -190,6 +190,7 @@ DAXCTL_EXPORT void daxctl_region_unref(struct daxctl_region *region)
 	if (region->refcount)
 		return;
 
+	ctx = region->ctx;
 	info(ctx, "region%d released\n", region->id);
 	list_for_each_safe(&region->devices, dev, _d, list)
 		free_dev(dev, &region->devices);
-- 
2.8.2.335.g4bb51ae

  parent reply	other threads:[~2016-06-23 19:59 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
2016-06-23 19:59   ` Jeff Moyer [this message]
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=20160623195950.30968-3-jmoyer@redhat.com \
    --to=jmoyer-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@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.