projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'linux-linaro-lsk-v4.4-android' of git://git.linaro.org/kernel/linux...
[firefly-linux-kernel-4.4.55.git]
/
drivers
/
bluetooth
/
hci_vhci.c
diff --git
a/drivers/bluetooth/hci_vhci.c
b/drivers/bluetooth/hci_vhci.c
index ed888e302bc396f000035a63ac310686262fc924..597b2d16b775e3f2be4357c656cfed930e307ab3 100644
(file)
--- a/
drivers/bluetooth/hci_vhci.c
+++ b/
drivers/bluetooth/hci_vhci.c
@@
-50,6
+50,7
@@
struct vhci_data {
wait_queue_head_t read_wait;
struct sk_buff_head readq;
wait_queue_head_t read_wait;
struct sk_buff_head readq;
+ struct mutex open_mutex;
struct delayed_work open_timeout;
};
struct delayed_work open_timeout;
};
@@
-87,12
+88,15
@@
static int vhci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
return 0;
}
return 0;
}
-static int vhci_create_device(struct vhci_data *data, __u8 opcode)
+static int
__
vhci_create_device(struct vhci_data *data, __u8 opcode)
{
struct hci_dev *hdev;
struct sk_buff *skb;
__u8 dev_type;
{
struct hci_dev *hdev;
struct sk_buff *skb;
__u8 dev_type;
+ if (data->hdev)
+ return -EBADFD;
+
/* bits 0-1 are dev_type (BR/EDR or AMP) */
dev_type = opcode & 0x03;
/* bits 0-1 are dev_type (BR/EDR or AMP) */
dev_type = opcode & 0x03;
@@
-151,6
+155,17
@@
static int vhci_create_device(struct vhci_data *data, __u8 opcode)
return 0;
}
return 0;
}
+static int vhci_create_device(struct vhci_data *data, __u8 opcode)
+{
+ int err;
+
+ mutex_lock(&data->open_mutex);
+ err = __vhci_create_device(data, opcode);
+ mutex_unlock(&data->open_mutex);
+
+ return err;
+}
+
static inline ssize_t vhci_get_user(struct vhci_data *data,
struct iov_iter *from)
{
static inline ssize_t vhci_get_user(struct vhci_data *data,
struct iov_iter *from)
{
@@
-189,11
+204,6
@@
static inline ssize_t vhci_get_user(struct vhci_data *data,
break;
case HCI_VENDOR_PKT:
break;
case HCI_VENDOR_PKT:
- if (data->hdev) {
- kfree_skb(skb);
- return -EBADFD;
- }
-
cancel_delayed_work_sync(&data->open_timeout);
opcode = *((__u8 *) skb->data);
cancel_delayed_work_sync(&data->open_timeout);
opcode = *((__u8 *) skb->data);
@@
-320,6
+330,7
@@
static int vhci_open(struct inode *inode, struct file *file)
skb_queue_head_init(&data->readq);
init_waitqueue_head(&data->read_wait);
skb_queue_head_init(&data->readq);
init_waitqueue_head(&data->read_wait);
+ mutex_init(&data->open_mutex);
INIT_DELAYED_WORK(&data->open_timeout, vhci_open_timeout);
file->private_data = data;
INIT_DELAYED_WORK(&data->open_timeout, vhci_open_timeout);
file->private_data = data;
@@
-333,15
+344,18
@@
static int vhci_open(struct inode *inode, struct file *file)
static int vhci_release(struct inode *inode, struct file *file)
{
struct vhci_data *data = file->private_data;
static int vhci_release(struct inode *inode, struct file *file)
{
struct vhci_data *data = file->private_data;
- struct hci_dev *hdev
= data->hdev
;
+ struct hci_dev *hdev;
cancel_delayed_work_sync(&data->open_timeout);
cancel_delayed_work_sync(&data->open_timeout);
+ hdev = data->hdev;
+
if (hdev) {
hci_unregister_dev(hdev);
hci_free_dev(hdev);
}
if (hdev) {
hci_unregister_dev(hdev);
hci_free_dev(hdev);
}
+ skb_queue_purge(&data->readq);
file->private_data = NULL;
kfree(data);
file->private_data = NULL;
kfree(data);