From: Peter Hurley Date: Mon, 10 Feb 2014 01:59:21 +0000 (-0500) Subject: Bluetooth: Force -EIO from tty read/write if .activate() fails X-Git-Tag: Ubuntu-snapdragon-4.4.0-1050.54~10572^2~159^2^2~130^2~53 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=5326a4ee982703ddba14a9821fe5cb10d122e1b0;hp=fb856e50900a84dd9f8d50d3882eb4a26ba6ea54;p=mirror_ubuntu-artful-kernel.git Bluetooth: Force -EIO from tty read/write if .activate() fails If rfcomm_dlc_open() fails, set tty into error state which returns -EIO from reads and writes. Signed-off-by: Peter Hurley Tested-By: Alexander Holler Signed-off-by: Marcel Holtmann --- diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 375b60dae04d..f6b9f0c4c29e 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -111,8 +111,12 @@ static void rfcomm_dev_destruct(struct tty_port *port) static int rfcomm_dev_activate(struct tty_port *port, struct tty_struct *tty) { struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); + int err; - return rfcomm_dlc_open(dev->dlc, &dev->src, &dev->dst, dev->channel); + err = rfcomm_dlc_open(dev->dlc, &dev->src, &dev->dst, dev->channel); + if (err) + set_bit(TTY_IO_ERROR, &tty->flags); + return err; } /* we block the open until the dlc->state becomes BT_CONNECTED */