Linux PCI Non-Transparent Bridge framework and drivers
 help / color / mirror / Atom feed
From: Gary R Hook <gary.hook@amd.com>
To: linux-ntb@googlegroups.com
Cc: Allen.Hubbe@emc.com, dave.jiang@intel.com, jdmason@kudzu.us
Subject: [PATCH] ntb: Add error path/handling to Debug FS entry creation
Date: Mon, 15 May 2017 10:33:27 -0500	[thread overview]
Message-ID: <20170515153327.4400.83250.stgit@taos.amd.com> (raw)

If a failure occurs when creating Debug FS entries, unroll all of
the work that's been done.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
 drivers/ntb/test/ntb_perf.c |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index 6fdddf86269e..759f772fa00c 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -745,6 +745,7 @@ static int perf_debugfs_setup(struct perf_ctx *perf)
 	if (!debugfs_initialized())
 		return -ENODEV;
 
+	/* Assumpion: only one NTB device in the system */
 	if (!perf_debugfs_dir) {
 		perf_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
 		if (!perf_debugfs_dir)
@@ -754,45 +755,50 @@ static int perf_debugfs_setup(struct perf_ctx *perf)
 	debugfs_node_dir = debugfs_create_dir(pci_name(pdev),
 					      perf_debugfs_dir);
 	if (!debugfs_node_dir)
-		return -ENODEV;
+		goto err;
 
 	debugfs_run = debugfs_create_file("run", S_IRUSR | S_IWUSR,
 					  debugfs_node_dir, perf,
 					  &ntb_perf_debugfs_run);
 	if (!debugfs_run)
-		return -ENODEV;
+		goto err;
 
 	debugfs_threads = debugfs_create_u8("threads", S_IRUSR | S_IWUSR,
 					    debugfs_node_dir,
 					    &perf->perf_threads);
 	if (!debugfs_threads)
-		return -ENODEV;
+		goto err;
 
 	debugfs_seg_order = debugfs_create_u32("seg_order", 0600,
 					       debugfs_node_dir,
 					       &seg_order);
 	if (!debugfs_seg_order)
-		return -ENODEV;
+		goto err;
 
 	debugfs_run_order = debugfs_create_u32("run_order", 0600,
 					       debugfs_node_dir,
 					       &run_order);
 	if (!debugfs_run_order)
-		return -ENODEV;
+		goto err;
 
 	debugfs_use_dma = debugfs_create_bool("use_dma", 0600,
 					       debugfs_node_dir,
 					       &use_dma);
 	if (!debugfs_use_dma)
-		return -ENODEV;
+		goto err;
 
 	debugfs_on_node = debugfs_create_bool("on_node", 0600,
 					      debugfs_node_dir,
 					      &on_node);
 	if (!debugfs_on_node)
-		return -ENODEV;
+		goto err;
 
 	return 0;
+
+err:
+	debugfs_remove_recursive(perf_debugfs_dir);
+	perf_debugfs_dir = NULL;
+	return -ENODEV;
 }
 
 static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb)


             reply	other threads:[~2017-05-15 15:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15 15:33 Gary R Hook [this message]
2017-05-15 16:34 ` [PATCH] ntb: Add error path/handling to Debug FS entry creation Dave Jiang

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=20170515153327.4400.83250.stgit@taos.amd.com \
    --to=gary.hook@amd.com \
    --cc=Allen.Hubbe@emc.com \
    --cc=dave.jiang@intel.com \
    --cc=jdmason@kudzu.us \
    --cc=linux-ntb@googlegroups.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox