Skip to content

Commit

Permalink
Bluetooth: Correctly acquire module ref
Browse files Browse the repository at this point in the history
We provide a device-object to other subsystems and we provide our own
release-function. Therefore, the device-object must own a reference to
our module, otherwise the release-function may get deleted before the
device-object does.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
  • Loading branch information
David Herrmann authored and Johan Hedberg committed Feb 13, 2012
1 parent 587ae08 commit 46e0653
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/bluetooth/hci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ static void bt_host_release(struct device *dev)
{
void *data = dev_get_drvdata(dev);
kfree(data);
module_put(THIS_MODULE);
}

static struct device_type bt_host = {
Expand Down Expand Up @@ -523,6 +524,7 @@ void hci_init_sysfs(struct hci_dev *hdev)
dev->type = &bt_host;
dev->class = bt_class;

__module_get(THIS_MODULE);
dev_set_drvdata(dev, hdev);
device_initialize(dev);
}
Expand Down

0 comments on commit 46e0653

Please sign in to comment.