浏览代码

Bluetooth: Fix context in RFCOMM tty

We now run in process context, no need to disable interrupts.
Calls from the tty layer also run in process context.

rw_lock was converted to spinlock, we have more writers than readers in
this case.

Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Gustavo F. Padovan 13 年之前
父节点
当前提交
393432cd8d
共有 1 个文件被更改,包括 11 次插入11 次删除
  1. 11 11
      net/bluetooth/rfcomm/tty.c

+ 11 - 11
net/bluetooth/rfcomm/tty.c

@@ -76,7 +76,7 @@ struct rfcomm_dev {
 };
 };
 
 
 static LIST_HEAD(rfcomm_dev_list);
 static LIST_HEAD(rfcomm_dev_list);
-static DEFINE_RWLOCK(rfcomm_dev_lock);
+static DEFINE_SPINLOCK(rfcomm_dev_lock);
 
 
 static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb);
 static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb);
 static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err);
 static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err);
@@ -146,7 +146,7 @@ static inline struct rfcomm_dev *rfcomm_dev_get(int id)
 {
 {
 	struct rfcomm_dev *dev;
 	struct rfcomm_dev *dev;
 
 
-	read_lock(&rfcomm_dev_lock);
+	spin_lock(&rfcomm_dev_lock);
 
 
 	dev = __rfcomm_dev_get(id);
 	dev = __rfcomm_dev_get(id);
 
 
@@ -157,7 +157,7 @@ static inline struct rfcomm_dev *rfcomm_dev_get(int id)
 			rfcomm_dev_hold(dev);
 			rfcomm_dev_hold(dev);
 	}
 	}
 
 
-	read_unlock(&rfcomm_dev_lock);
+	spin_unlock(&rfcomm_dev_lock);
 
 
 	return dev;
 	return dev;
 }
 }
@@ -205,7 +205,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
 	if (!dev)
 	if (!dev)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
-	write_lock_bh(&rfcomm_dev_lock);
+	spin_lock(&rfcomm_dev_lock);
 
 
 	if (req->dev_id < 0) {
 	if (req->dev_id < 0) {
 		dev->id = 0;
 		dev->id = 0;
@@ -290,7 +290,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
 	__module_get(THIS_MODULE);
 	__module_get(THIS_MODULE);
 
 
 out:
 out:
-	write_unlock_bh(&rfcomm_dev_lock);
+	spin_unlock(&rfcomm_dev_lock);
 
 
 	if (err < 0)
 	if (err < 0)
 		goto free;
 		goto free;
@@ -327,9 +327,9 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
 	if (atomic_read(&dev->opened) > 0)
 	if (atomic_read(&dev->opened) > 0)
 		return;
 		return;
 
 
-	write_lock_bh(&rfcomm_dev_lock);
+	spin_lock(&rfcomm_dev_lock);
 	list_del_init(&dev->list);
 	list_del_init(&dev->list);
-	write_unlock_bh(&rfcomm_dev_lock);
+	spin_unlock(&rfcomm_dev_lock);
 
 
 	rfcomm_dev_put(dev);
 	rfcomm_dev_put(dev);
 }
 }
@@ -473,7 +473,7 @@ static int rfcomm_get_dev_list(void __user *arg)
 
 
 	di = dl->dev_info;
 	di = dl->dev_info;
 
 
-	read_lock_bh(&rfcomm_dev_lock);
+	spin_lock(&rfcomm_dev_lock);
 
 
 	list_for_each_entry(dev, &rfcomm_dev_list, list) {
 	list_for_each_entry(dev, &rfcomm_dev_list, list) {
 		if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags))
 		if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags))
@@ -488,7 +488,7 @@ static int rfcomm_get_dev_list(void __user *arg)
 			break;
 			break;
 	}
 	}
 
 
-	read_unlock_bh(&rfcomm_dev_lock);
+	spin_unlock(&rfcomm_dev_lock);
 
 
 	dl->dev_num = n;
 	dl->dev_num = n;
 	size = sizeof(*dl) + n * sizeof(*di);
 	size = sizeof(*dl) + n * sizeof(*di);
@@ -766,9 +766,9 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
 		rfcomm_dlc_unlock(dev->dlc);
 		rfcomm_dlc_unlock(dev->dlc);
 
 
 		if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) {
 		if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) {
-			write_lock_bh(&rfcomm_dev_lock);
+			spin_lock(&rfcomm_dev_lock);
 			list_del_init(&dev->list);
 			list_del_init(&dev->list);
-			write_unlock_bh(&rfcomm_dev_lock);
+			spin_unlock(&rfcomm_dev_lock);
 
 
 			rfcomm_dev_put(dev);
 			rfcomm_dev_put(dev);
 		}
 		}