diff options
author | Adam Lee <adam8157@gmail.com> | 2013-07-09 22:02:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-11 21:35:23 -0400 |
commit | ea788759177526b7a103baed9c711d284d822fe5 (patch) | |
tree | d37df50e005f836fef3c7320bed5d3ca8ca57697 | |
parent | c519774d4e636eeea2c1490c179fb898bbc61c17 (diff) |
Bluetooth: fix wrong use of PTR_ERR() in btusb
commit d9c78e9738ccd0017b10b8f44462aafb61904a4a upstream.
PTR_ERR() returns a signed long type value which is limited by IS_ERR(),
it must be a negative number whose range is [-MAX_ERRNO, 0).
The bug here returns negative numbers as error codes, then check it by
"if (ret < 0)", but -PTR_ERR() is actually positive. The wrong use here
leads to failure as below, even panic.
[ 12.958920] Bluetooth: hci0 command 0xfc8e tx timeout
[ 14.961765] Bluetooth: hci0 command 0xfc8e tx timeout
[ 16.964688] Bluetooth: hci0 command 0xfc8e tx timeout
[ 20.954501] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110)
[ 22.957358] Bluetooth: hci0 command 0xfc8e tx timeout
[ 30.948922] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110)
[ 32.951780] Bluetooth: hci0 command 0xfc8e tx timeout
[ 40.943359] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110)
[ 42.946219] Bluetooth: hci0 command 0xfc8e tx timeout
[ 50.937812] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110)
[ 52.940670] Bluetooth: hci0 command 0xfc8e tx timeout
[ 60.932236] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110)
[ 62.935092] Bluetooth: hci0 command 0xfc8e tx timeout
[ 70.926688] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110)
[ 72.929545] Bluetooth: hci0 command 0xfc8e tx timeout
[ 80.921111] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110)
[ 82.923969] Bluetooth: hci0 command 0xfc2f tx timeout
[ 90.915542] Bluetooth: hci0 sending Intel patch command (0xfc2f) failed (-110)
[ 92.918406] Bluetooth: hci0 command 0xfc11 tx timeout
[ 100.909955] Bluetooth: hci0 sending Intel patch command (0xfc11) failed (-110)
[ 102.912858] Bluetooth: hci0 command 0xfc60 tx timeout
[ 110.904394] Bluetooth: hci0 sending Intel patch command (0xfc60) failed (-110)
[ 112.907293] Bluetooth: hci0 command 0xfc11 tx timeout
[ 120.898831] Bluetooth: hci0 exiting Intel manufacturer mode failed (-110)
[ 120.904757] bluetoothd[1030]: segfault at 4 ip 00007f8b2eb55236 sp 00007fff53ff6920 error 4 in bluetoothd[7f8b2eaff000+cb000]
Signed-off-by: Adam Lee <adam.lee@canonical.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/bluetooth/btusb.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index b852884397b9..d0b3d900d452 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -1099,7 +1099,7 @@ static int btusb_setup_intel_patching(struct hci_dev *hdev, | |||
1099 | if (IS_ERR(skb)) { | 1099 | if (IS_ERR(skb)) { |
1100 | BT_ERR("%s sending Intel patch command (0x%4.4x) failed (%ld)", | 1100 | BT_ERR("%s sending Intel patch command (0x%4.4x) failed (%ld)", |
1101 | hdev->name, cmd->opcode, PTR_ERR(skb)); | 1101 | hdev->name, cmd->opcode, PTR_ERR(skb)); |
1102 | return -PTR_ERR(skb); | 1102 | return PTR_ERR(skb); |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | /* It ensures that the returned event matches the event data read from | 1105 | /* It ensures that the returned event matches the event data read from |
@@ -1151,7 +1151,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) | |||
1151 | if (IS_ERR(skb)) { | 1151 | if (IS_ERR(skb)) { |
1152 | BT_ERR("%s sending initial HCI reset command failed (%ld)", | 1152 | BT_ERR("%s sending initial HCI reset command failed (%ld)", |
1153 | hdev->name, PTR_ERR(skb)); | 1153 | hdev->name, PTR_ERR(skb)); |
1154 | return -PTR_ERR(skb); | 1154 | return PTR_ERR(skb); |
1155 | } | 1155 | } |
1156 | kfree_skb(skb); | 1156 | kfree_skb(skb); |
1157 | 1157 | ||
@@ -1165,7 +1165,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) | |||
1165 | if (IS_ERR(skb)) { | 1165 | if (IS_ERR(skb)) { |
1166 | BT_ERR("%s reading Intel fw version command failed (%ld)", | 1166 | BT_ERR("%s reading Intel fw version command failed (%ld)", |
1167 | hdev->name, PTR_ERR(skb)); | 1167 | hdev->name, PTR_ERR(skb)); |
1168 | return -PTR_ERR(skb); | 1168 | return PTR_ERR(skb); |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | if (skb->len != sizeof(*ver)) { | 1171 | if (skb->len != sizeof(*ver)) { |
@@ -1223,7 +1223,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) | |||
1223 | BT_ERR("%s entering Intel manufacturer mode failed (%ld)", | 1223 | BT_ERR("%s entering Intel manufacturer mode failed (%ld)", |
1224 | hdev->name, PTR_ERR(skb)); | 1224 | hdev->name, PTR_ERR(skb)); |
1225 | release_firmware(fw); | 1225 | release_firmware(fw); |
1226 | return -PTR_ERR(skb); | 1226 | return PTR_ERR(skb); |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | if (skb->data[0]) { | 1229 | if (skb->data[0]) { |
@@ -1280,7 +1280,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) | |||
1280 | if (IS_ERR(skb)) { | 1280 | if (IS_ERR(skb)) { |
1281 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", | 1281 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", |
1282 | hdev->name, PTR_ERR(skb)); | 1282 | hdev->name, PTR_ERR(skb)); |
1283 | return -PTR_ERR(skb); | 1283 | return PTR_ERR(skb); |
1284 | } | 1284 | } |
1285 | kfree_skb(skb); | 1285 | kfree_skb(skb); |
1286 | 1286 | ||
@@ -1296,7 +1296,7 @@ exit_mfg_disable: | |||
1296 | if (IS_ERR(skb)) { | 1296 | if (IS_ERR(skb)) { |
1297 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", | 1297 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", |
1298 | hdev->name, PTR_ERR(skb)); | 1298 | hdev->name, PTR_ERR(skb)); |
1299 | return -PTR_ERR(skb); | 1299 | return PTR_ERR(skb); |
1300 | } | 1300 | } |
1301 | kfree_skb(skb); | 1301 | kfree_skb(skb); |
1302 | 1302 | ||
@@ -1314,7 +1314,7 @@ exit_mfg_deactivate: | |||
1314 | if (IS_ERR(skb)) { | 1314 | if (IS_ERR(skb)) { |
1315 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", | 1315 | BT_ERR("%s exiting Intel manufacturer mode failed (%ld)", |
1316 | hdev->name, PTR_ERR(skb)); | 1316 | hdev->name, PTR_ERR(skb)); |
1317 | return -PTR_ERR(skb); | 1317 | return PTR_ERR(skb); |
1318 | } | 1318 | } |
1319 | kfree_skb(skb); | 1319 | kfree_skb(skb); |
1320 | 1320 | ||