From: Johan Hedberg Date: Mon, 7 Nov 2011 21:13:37 +0000 (+0200) Subject: Bluetooth: Fix response for mgmt_start_discovery when powered off X-Git-Tag: v3.12-rc1~4160^2~44^2~536^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd2d1334e1dd64765b29f9e1b592777c410ed121;p=kernel%2Fkernel-generic.git Bluetooth: Fix response for mgmt_start_discovery when powered off We should return a ENETDOWN status response if the adapter is powered off (i.e. the HCI_UP flag isn't set). Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan --- diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index e33b12e..af077ab 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1619,6 +1619,11 @@ static int start_discovery(struct sock *sk, u16 index) hci_dev_lock_bh(hdev); + if (!test_bit(HCI_UP, &hdev->flags)) { + err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY, ENETDOWN); + goto failed; + } + cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, index, NULL, 0); if (!cmd) { err = -ENOMEM;