All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH 2/5] ndctl: fix blk-ns test cleanup
Date: Wed, 16 Mar 2016 17:54:40 -0700	[thread overview]
Message-ID: <20160317005440.3025.71496.stgit@dwillia2-desk3.jf.intel.com> (raw)
In-Reply-To: <20160317005429.3025.395.stgit@dwillia2-desk3.jf.intel.com>

ndctl_namespace_foreach_safe() needs to be used when a namespace is
deleted while iterating.  Otherwise, we can walk off into uninitialized
memory and segfault.

Reported-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/blk_namespaces.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
index 968af2797feb..41c5ce0b1bd7 100644
--- a/test/blk_namespaces.c
+++ b/test/blk_namespaces.c
@@ -214,7 +214,7 @@ int test_blk_namespaces(int log_level)
 	char bdev[50];
 	struct ndctl_ctx *ctx;
 	struct ndctl_bus *bus;
-	struct ndctl_namespace *ndns[2];
+	struct ndctl_namespace *ndns[2], *_n;
 	struct ndctl_region *region, *blk_region = NULL;
 	struct ndctl_dimm *dimm;
 
@@ -307,7 +307,7 @@ int test_blk_namespaces(int log_level)
 
  err_cleanup:
 	if (blk_region) {
-		ndctl_namespace_foreach(blk_region, ndns[0])
+		ndctl_namespace_foreach_safe(blk_region, ndns[0], _n)
 			if (ndctl_namespace_get_size(ndns[0]) != 0)
 				disable_blk_namespace(ndns[0]);
 	}

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  parent reply	other threads:[~2016-03-17  0:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17  0:54 [ndctl PATCH 0/5] refresh 'ndctl bat' tests and other misc updates Dan Williams
2016-03-17  0:54 ` [ndctl PATCH 1/5] ndctl: update pkg-config description Dan Williams
2016-03-17  0:54 ` Dan Williams [this message]
2016-03-17  0:54 ` [ndctl PATCH 3/5] Revert "ndctl: fix error handling in ND_BLK & PMEM tests" Dan Williams
2016-03-17  0:54 ` [ndctl PATCH 4/5] ndctl: convert 'ndctl bat' to use struct ndctl_test Dan Williams
2016-03-17  0:54 ` [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns Dan Williams
2016-03-18 16:24   ` Ross Zwisler
2016-03-18 16:48     ` Dan Williams

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=20160317005440.3025.71496.stgit@dwillia2-desk3.jf.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.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.