Linux bluetooth development
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 2/2] Bluetooth: Add proper cleanup path for bt_6lowpan_init()
Date: Wed, 18 Mar 2015 11:10:40 +0200	[thread overview]
Message-ID: <1426669840-2933-2-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1426669840-2933-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

In case part of the bt_6lowpan_init() fails we should undo any
operations that succeeded before the failure. This patch add the
necessary cleanup path to the function.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/6lowpan.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 524218aeea6f..6e3c208820b8 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -1457,9 +1457,20 @@ static int __init bt_6lowpan_init(void)
 
 	err = register_netdevice_notifier(&bt_6lowpan_dev_notifier);
 	if (err)
-		return err;
+		goto failed;
 
-	return hci_mgmt_chan_register(&bt_6lowpan_chan);
+	err = hci_mgmt_chan_register(&bt_6lowpan_chan);
+	if (err) {
+		unregister_netdevice_notifier(&bt_6lowpan_dev_notifier);
+		goto failed;
+	}
+
+	return 0;
+
+failed:
+	debugfs_remove(lowpan_enable_debugfs);
+	debugfs_remove(lowpan_control_debugfs);
+	return err;
 }
 
 static void __exit bt_6lowpan_exit(void)
-- 
2.1.0


  reply	other threads:[~2015-03-18  9:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18  9:10 [PATCH 1/2] Bluetooth: Add skeleton for 6LoWPAN mgmt command handling Johan Hedberg
2015-03-18  9:10 ` Johan Hedberg [this message]
2015-03-18 12:47 ` Jukka Rissanen

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=1426669840-2933-2-git-send-email-johan.hedberg@gmail.com \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox