linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gustavo Padovan <padovan@profusion.mobi>
To: David Herrmann <dh.herrmann@googlemail.com>
Cc: linux-bluetooth@vger.kernel.org, marcel@holtmann.org
Subject: Re: [PATCH 1/3] Bluetooth: Fix hci core device initialization
Date: Mon, 10 Oct 2011 15:44:42 -0300	[thread overview]
Message-ID: <20111010184442.GA6936@joana> (raw)
In-Reply-To: <1318078729-4158-1-git-send-email-dh.herrmann@googlemail.com>

Hi David,

* David Herrmann <dh.herrmann@googlemail.com> [2011-10-08 14:58:47 +0200]:

> We must not call device_del() if we didn't use device_add(). See module.c for
> comments on that. Therefore, we need to call device_initialize() when allocating
> the hci device and later device_add() instead of device_register().
> 
> This also fixes a bug when hci_register_dev() failed and we call hci_free_dev()
> without a valid core device. hci_free_dev() segfaults while calling put_device()
> on invalid memory.

Please let me know if the following diff also fixes this problem.
It seems to fixes other issues like failing in usb_driver_claim_interface().

	Gustavo


diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b84458d..ac446a7 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -922,9 +922,6 @@ EXPORT_SYMBOL(hci_alloc_dev);
 void hci_free_dev(struct hci_dev *hdev)
 {
        skb_queue_purge(&hdev->driver_init);
-
-       /* will free via device release */
-       put_device(&hdev->dev);
 }
 EXPORT_SYMBOL(hci_free_dev);
 
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 22f1a6c..1e5ccde 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -587,7 +587,7 @@ void hci_unregister_sysfs(struct hci_dev *hdev)
 
        debugfs_remove_recursive(hdev->debugfs);
 
-       device_del(&hdev->dev);
+       device_unregister(&hdev->dev);
 }
 
 int __init bt_sysfs_init(void)

  parent reply	other threads:[~2011-10-10 18:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-08 12:58 [PATCH 1/3] Bluetooth: Fix hci core device initialization David Herrmann
2011-10-08 12:58 ` [PATCH 2/3] Bluetooth: Rename sysfs un/register to add/del David Herrmann
2011-10-08 12:58 ` [PATCH 3/3] Bluetooth: Forward errors from hci_register_dev David Herrmann
2011-10-10 18:44 ` Gustavo Padovan [this message]
2011-10-11 12:35   ` [PATCH 1/3] Bluetooth: Fix hci core device initialization David Herrmann
2011-10-13 20:51     ` Gustavo Padovan

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=20111010184442.GA6936@joana \
    --to=padovan@profusion.mobi \
    --cc=dh.herrmann@googlemail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.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;
as well as URLs for NNTP newsgroup(s).