Skip to content

Commit bf18c71

Browse files
David HerrmannJohan Hedberg
authored andcommitted
Bluetooth: vhci: Free driver_data on file release
This removes the hci-destruct callback and instead frees the private driver data in the vhci_release file release function. There is no reason to keep private driver data available if the driver has already shut down. After vhci_release is called our module can be unloaded. The only reason it is kept alive is the hci-core having a module-ref on us because of our destruct callback. However, this callback only frees hdev->driver_data. That is, we wait for the hdev-device to get destroyed to free our internal driver-data. In fact, the hci-core does never touch hdev->driver_data so it doesn't care if it is NULL. Therefore, we simply free it when unloading the driver. Another important fact is that the hdev core does not call any callbacks other than the destruct-cb after hci_unregister_dev() has been called. So there is no function of our module that will be called nor does the hci-core touch hdev->driver_data. Hence, no other code can touch hdev->driver_data after our cleanup so the destruct callback is definitely unnecessary here. Signed-off-by: David Herrmann <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
1 parent aed014a commit bf18c71

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

drivers/bluetooth/hci_vhci.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ static int vhci_send_frame(struct sk_buff *skb)
103103
return 0;
104104
}
105105

106-
static void vhci_destruct(struct hci_dev *hdev)
107-
{
108-
kfree(hdev->driver_data);
109-
}
110-
111106
static inline ssize_t vhci_get_user(struct vhci_data *data,
112107
const char __user *buf, size_t count)
113108
{
@@ -248,7 +243,6 @@ static int vhci_open(struct inode *inode, struct file *file)
248243
hdev->close = vhci_close_dev;
249244
hdev->flush = vhci_flush;
250245
hdev->send = vhci_send_frame;
251-
hdev->destruct = vhci_destruct;
252246

253247
hdev->owner = THIS_MODULE;
254248

@@ -273,6 +267,7 @@ static int vhci_release(struct inode *inode, struct file *file)
273267
hci_free_dev(hdev);
274268

275269
file->private_data = NULL;
270+
kfree(data);
276271

277272
return 0;
278273
}

0 commit comments

Comments
 (0)