* [bug report] Bluetooth: btusb: Add support for Qualcomm multi-subsystem QCC2072
@ 2026-09-17 19:15 Dan Carpenter
2026-09-17 19:17 ` Dan Carpenter
0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2026-09-17 19:15 UTC (permalink / raw)
To: Zijun Hu; +Cc: linux-bluetooth
Hello Zijun Hu,
Commit 2e63b55654e0 ("Bluetooth: btusb: Add support for Qualcomm
multi-subsystem QCC2072") from Sep 13, 2026 (linux-next), leads to
the following Smatch static checker warning:
drivers/bluetooth/btusb_qcom.c:2516 btqcom_set_bdaddr()
warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
drivers/bluetooth/btusb_qcom.c
2507 *
2508 * Return: 0 on success, or a negative errno on failure.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2509 */
2510 static int btqcom_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
2511 {
2512 int ret;
2513
2514 ret = __hci_reset_sync(hdev);
2515 if (ret) {
--> 2516 bt_dev_err(hdev, "HCI reset before setting BD_ADDR failed: %pe",
2517 ERR_PTR(ret));
2518 return ret;
ret comes from skb->data in __hci_cmd_sync_status_sk() so it's a u8 and
not necessarily a negative error code.
2519 }
2520
2521 ret = qbt_write_bda(hdev, bdaddr);
2522
2523 return ret;
2524 }
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [bug report] Bluetooth: btusb: Add support for Qualcomm multi-subsystem QCC2072
2026-09-17 19:15 [bug report] Bluetooth: btusb: Add support for Qualcomm multi-subsystem QCC2072 Dan Carpenter
@ 2026-09-17 19:17 ` Dan Carpenter
2026-09-19 2:36 ` Zijun Hu
0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2026-09-17 19:17 UTC (permalink / raw)
To: Zijun Hu; +Cc: linux-bluetooth
On Thu, Sep 17, 2026 at 10:15:22PM +0300, Dan Carpenter wrote:
> Hello Zijun Hu,
>
> Commit 2e63b55654e0 ("Bluetooth: btusb: Add support for Qualcomm
> multi-subsystem QCC2072") from Sep 13, 2026 (linux-next), leads to
> the following Smatch static checker warning:
>
> drivers/bluetooth/btusb_qcom.c:2516 btqcom_set_bdaddr()
> warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
>
See also:
drivers/bluetooth/btusb_qcom.c:2931 btusb_qcom_shutdown_unified() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
drivers/bluetooth/btusb_qcom.c:2947 btusb_qcom_shutdown_unified() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
drivers/bluetooth/btusb_qcom.c:3562 btusb_post_download_unified_bt() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
drivers/bluetooth/btusb_qcom.c:3977 btusb_qcom_setup_unified() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [bug report] Bluetooth: btusb: Add support for Qualcomm multi-subsystem QCC2072
2026-09-17 19:17 ` Dan Carpenter
@ 2026-09-19 2:36 ` Zijun Hu
2026-09-19 5:07 ` Dan Carpenter
0 siblings, 1 reply; 6+ messages in thread
From: Zijun Hu @ 2026-09-19 2:36 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-bluetooth
On 9/18/2026 3:17 AM, Dan Carpenter wrote:
> See also:
>
> drivers/bluetooth/btusb_qcom.c:2931 btusb_qcom_shutdown_unified() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
> drivers/bluetooth/btusb_qcom.c:2947 btusb_qcom_shutdown_unified() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
> drivers/bluetooth/btusb_qcom.c:3562 btusb_post_download_unified_bt() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
> drivers/bluetooth/btusb_qcom.c:3977 btusb_qcom_setup_unified() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
Thanks for the report.
But All reported cases are false positives: __hci_reset_sync() always returns
0 or a negative errno, *never* a positive value.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [bug report] Bluetooth: btusb: Add support for Qualcomm multi-subsystem QCC2072
2026-09-19 2:36 ` Zijun Hu
@ 2026-09-19 5:07 ` Dan Carpenter
2026-09-19 7:04 ` Zijun Hu
0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2026-09-19 5:07 UTC (permalink / raw)
To: Zijun Hu; +Cc: linux-bluetooth
On Sat, Sep 19, 2026 at 10:36:37AM +0800, Zijun Hu wrote:
> On 9/18/2026 3:17 AM, Dan Carpenter wrote:
> > See also:
> >
> > drivers/bluetooth/btusb_qcom.c:2931 btusb_qcom_shutdown_unified() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
> > drivers/bluetooth/btusb_qcom.c:2947 btusb_qcom_shutdown_unified() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
> > drivers/bluetooth/btusb_qcom.c:3562 btusb_post_download_unified_bt() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
> > drivers/bluetooth/btusb_qcom.c:3977 btusb_qcom_setup_unified() warn: passing positive error code '(-4095)-(-62),(-60)-(-1),1-255' to 'ERR_PTR'
>
> Thanks for the report.
>
> But All reported cases are false positives: __hci_reset_sync() always returns
> 0 or a negative errno, *never* a positive value.
The return values come from here.
net/bluetooth/hci_sync.c
256 int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
257 const void *param, u8 event, u32 timeout,
258 struct sock *sk)
259 {
260 struct sk_buff *skb;
261 u8 status;
262
263 skb = __hci_cmd_sync_sk(hdev, opcode, plen, param, event, timeout, sk);
264
265 /* If command return a status event, skb will be set to -ENODATA */
266 if (skb == ERR_PTR(-ENODATA))
267 return 0;
^^^^^^^^
Zero, sure.
268
269 if (IS_ERR(skb)) {
270 if (!event)
271 bt_dev_err(hdev, "Opcode 0x%4.4x failed: %ld", opcode,
272 PTR_ERR(skb));
273 return PTR_ERR(skb);
^^^^^^^^^^^^^^^^^^^
Error pointer. Fine.
274 }
275
276 status = skb->data[0];
277
278 kfree_skb(skb);
279
280 return status;
^^^^^^^^^^^^^
But this seems like it could be a positive...
281 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [bug report] Bluetooth: btusb: Add support for Qualcomm multi-subsystem QCC2072
2026-09-19 5:07 ` Dan Carpenter
@ 2026-09-19 7:04 ` Zijun Hu
2026-09-19 10:43 ` Dan Carpenter
0 siblings, 1 reply; 6+ messages in thread
From: Zijun Hu @ 2026-09-19 7:04 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-bluetooth
On 9/19/2026 1:07 PM, Dan Carpenter wrote:
> Zero, sure.
>
> 268
> 269 if (IS_ERR(skb)) {
> 270 if (!event)
> 271 bt_dev_err(hdev, "Opcode 0x%4.4x failed: %ld", opcode,
> 272 PTR_ERR(skb));
> 273 return PTR_ERR(skb);
> ^^^^^^^^^^^^^^^^^^^
> Error pointer. Fine.
>
> 274 }
> 275
> 276 status = skb->data[0];
> 277
> 278 kfree_skb(skb);
> 279
> 280 return status;
> ^^^^^^^^^^^^^
> But this seems like it could be a positive...
>
For HCI_OP_RESET, execution cannot reach this point when status != 0.
> 281 }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [bug report] Bluetooth: btusb: Add support for Qualcomm multi-subsystem QCC2072
2026-09-19 7:04 ` Zijun Hu
@ 2026-09-19 10:43 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2026-09-19 10:43 UTC (permalink / raw)
To: Zijun Hu; +Cc: linux-bluetooth
On Sat, Sep 19, 2026 at 03:04:06PM +0800, Zijun Hu wrote:
> On 9/19/2026 1:07 PM, Dan Carpenter wrote:
> > Zero, sure.
> >
> > 268
> > 269 if (IS_ERR(skb)) {
> > 270 if (!event)
> > 271 bt_dev_err(hdev, "Opcode 0x%4.4x failed: %ld", opcode,
> > 272 PTR_ERR(skb));
> > 273 return PTR_ERR(skb);
> > ^^^^^^^^^^^^^^^^^^^
> > Error pointer. Fine.
> >
> > 274 }
> > 275
> > 276 status = skb->data[0];
> > 277
> > 278 kfree_skb(skb);
> > 279
> > 280 return status;
> > ^^^^^^^^^^^^^
> > But this seems like it could be a positive...
> >
>
> For HCI_OP_RESET, execution cannot reach this point when status != 0.
>
> > 281 }
Actually even for the other opcodes it looks like doing:
status = skb->data[0];
return status;
is just a more complicated way to write "return 0;". :/
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-19 10:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-17 19:15 [bug report] Bluetooth: btusb: Add support for Qualcomm multi-subsystem QCC2072 Dan Carpenter
2026-09-17 19:17 ` Dan Carpenter
2026-09-19 2:36 ` Zijun Hu
2026-09-19 5:07 ` Dan Carpenter
2026-09-19 7:04 ` Zijun Hu
2026-09-19 10:43 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox