diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 84fcf9f..917b441 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -129,6 +129,11 @@ static void rfcomm_dev_shutdown(struct tty_port *port) /* close the dlc */ rfcomm_dlc_close(dev->dlc, 0); + + /* release the port if it was created with the flag RELEASE_ONHUP */ + if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags) && + !test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags)) + tty_port_put(&dev->port); } static const struct tty_port_operations rfcomm_port_ops = {