• Peter Hurley's avatar
    Bluetooth: Fix unreleased rfcomm_dev reference · 80ea7337
    Peter Hurley authored
    When RFCOMM_RELEASE_ONHUP is set, the rfcomm tty driver 'takes over'
    the initial rfcomm_dev reference created by the RFCOMMCREATEDEV ioctl.
    The assumption is that the rfcomm tty driver will release the
    rfcomm_dev reference when the tty is freed (in rfcomm_tty_cleanup()).
    However, if the tty is never opened, the 'take over' never occurs,
    so when RFCOMMRELEASEDEV ioctl is called, the reference is not
    released.
    
    Track the state of the reference 'take over' so that the release
    is guaranteed by either the RFCOMMRELEASEDEV ioctl or the rfcomm tty
    driver.
    
    Note that the synchronous hangup in rfcomm_release_dev() ensures
    that rfcomm_tty_install() cannot race with the RFCOMMRELEASEDEV ioctl.
    Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
    Tested-By: default avatarAlexander Holler <holler@ahsoftware.de>
    Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
    80ea7337
rfcomm.h 9.03 KB