提交 77f2a45f 编写于 作者: M Marcel Holtmann

[Bluetooth] Check that device is in rfcomm_dev_list before deleting

If RFCOMM_RELEASE_ONHUP flag is on and rfcomm_release_dev is called
before connection is closed, rfcomm_dev is deleted twice from the
rfcomm_dev_list and refcount is messed up. This patch adds a check
before deleting device that the device actually is listed.
Signed-off-by: NVille Tervo <ville.tervo@nokia.com>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 48db9ca4
...@@ -517,9 +517,10 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err) ...@@ -517,9 +517,10 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err)
if (dlc->state == BT_CLOSED) { if (dlc->state == BT_CLOSED) {
if (!dev->tty) { if (!dev->tty) {
if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) { if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) {
rfcomm_dev_hold(dev); if (rfcomm_dev_get(dev->id) == NULL)
rfcomm_dev_del(dev); return;
rfcomm_dev_del(dev);
/* We have to drop DLC lock here, otherwise /* We have to drop DLC lock here, otherwise
rfcomm_dev_put() will dead lock if it's rfcomm_dev_put() will dead lock if it's
the last reference. */ the last reference. */
...@@ -974,8 +975,12 @@ static void rfcomm_tty_hangup(struct tty_struct *tty) ...@@ -974,8 +975,12 @@ static void rfcomm_tty_hangup(struct tty_struct *tty)
rfcomm_tty_flush_buffer(tty); rfcomm_tty_flush_buffer(tty);
if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) {
if (rfcomm_dev_get(dev->id) == NULL)
return;
rfcomm_dev_del(dev); rfcomm_dev_del(dev);
rfcomm_dev_put(dev);
}
} }
static int rfcomm_tty_read_proc(char *buf, char **start, off_t offset, int len, int *eof, void *unused) static int rfcomm_tty_read_proc(char *buf, char **start, off_t offset, int len, int *eof, void *unused)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册