]> git.baikalelectronics.ru Git - kernel.git/commit
Bluetooth: Release RFCOMM port when the last user closes the TTY
authorGianluca Anzolin <gianluca@sottospazio.it>
Mon, 6 Jan 2014 20:23:50 +0000 (21:23 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 6 Jan 2014 21:51:45 +0000 (13:51 -0800)
commitce9a5201f71efed0ed494754793eaf2a9564160f
treea138c1ce7fb63a0a966fc64e86a26d80b3f80f6d
parent000fb45c9ec15060521d1f7eebe81e24cac51c2e
Bluetooth: Release RFCOMM port when the last user closes the TTY

This patch fixes a userspace regression introduced by the commit
0af4465c.

If the rfcomm device was created with the flag RFCOMM_RELEASE_ONHUP the
user space expects that the tty_port is released as soon as the last
process closes the tty.

The current code attempts to release the port in the function
rfcomm_dev_state_change(). However it won't get a reference to the
relevant tty to send a HUP: at that point the tty is already destroyed
and therefore NULL.

This patch fixes the regression by taking over the tty refcount in the
tty install method(). This way the tty_port is automatically released as
soon as the tty is destroyed.

As a consequence the check for RFCOMM_RELEASE_ONHUP flag in the hangup()
method is now redundant. Instead we have to be careful with the reference
counting in the rfcomm_release_dev() function.

Signed-off-by: Gianluca Anzolin <gianluca@sottospazio.it>
Reported-by: Alexander Holler <holler@ahsoftware.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/rfcomm/tty.c