From: sashiko-bot@kernel.org
To: "Yanli Yang" <yanli.yang@bedmex.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [RFC PATCH bluetooth-next 3/3] Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport
Date: Thu, 17 Sep 2026 02:43:14 +0000 [thread overview]
Message-ID: <20260917024314.E65741F000FF@smtp.kernel.org> (raw)
In-Reply-To: <178954773705.2.3606741563381453586@bedmex.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] bluetooth: btaic: off-by-one in SDIO credit check causes timeout
- [High] bluetooth: btaic: missing SDIO transaction sequence numbers
- [High] bluetooth: btaic: UAF race in aic_bt_flush with RX path
- [High] bluetooth: btaic: deadlock in SDIO IRQ due to GFP_KERNEL allocation
- [Medium] bluetooth: btaic: UART max-speed DT property breaks firmware baud rate sync
--
commit c8b56eafa02e3f8c8946ccb2113f1c30e8b1cd4f
Author: Yanli Yang <yanli.yang@bedmex.com>
Subject: Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport
Adds a driver for the AIC8800D80 combination chip. It implements an SDIO
firmware loader and a serdev UART for H4 HCI traffic.
> diff --git a/drivers/bluetooth/btaic_sdio.c b/drivers/bluetooth/btaic_sdio.c
> --- a/drivers/bluetooth/btaic_sdio.c
> +++ b/drivers/bluetooth/btaic_sdio.c
[ ... ]
> static void aic_bt_complete_response(struct aic_bt_sdio *btdev,
> const struct aic_bt_e2a_header *message,
> size_t message_len)
> {
[ ... ]
> spin_lock_irqsave(&btdev->response_lock, flags);
> if (!btdev->waiting_response || id != btdev->expected_response)
> goto unlock;
[Severity: High]
Is there a risk of mismatched responses if a command times out?
In aic_bt_command(), a timeout clears waiting_response and aborts, leaving
the hardware state machine active:
spin_lock_irqsave(&btdev->response_lock, flags);
btdev->waiting_response = false;
btdev->response = NULL;
If a subsequent command of the same type is sent, and the hardware belatedly
responds to the timed-out request, aic_bt_complete_response() would accept
the late response since the expected_response ID matches. Could this corrupt
the initialization sequence?
[ ... ]
> static void aic_bt_sdio_irq(struct sdio_func *func)
> {
[ ... ]
> data = kmalloc(data_len, GFP_KERNEL);
[Severity: High]
Could this allocation deadlock under memory pressure?
The mmc core's sdio_irq_thread calls aic_bt_sdio_irq() with the mmc host lock
held. If GFP_KERNEL triggers direct reclaim, and reclaim tries to flush dirty
pages to a block device on the same mmc host, it would attempt to acquire the
host lock again, hanging the system.
[ ... ]
> static int aic_bt_wait_for_credits(struct aic_bt_sdio *btdev, size_t tx_len)
> {
[ ... ]
> for (retry = 0; retry < AIC_SDIO_FLOW_RETRIES; retry++) {
> u8 credits;
>
> credits = sdio_readb(btdev->func, AIC_SDIO_FLOW_CTRL_Q1, &err);
> if (err)
> return err;
>
> if (credits && tx_len < (size_t)credits * AIC_SDIO_BUFFER_SIZE)
> return 0;
[Severity: High]
Can this condition prevent transmission when exactly the right amount of
credits are available?
If the hardware grants exactly the required number of credits, this strictly
less-than check evaluates to false, causing the initialization to time out.
Should this be a <= check?
[ ... ]
> static u32 aic_bt_mode_value(unsigned int pair, u32 firmware_value)
> {
> switch (pair) {
[ ... ]
> case 5:
> return AIC_BT_UART_BAUD;
[Severity: Medium]
Does this firmware configuration get out of sync with the device tree speed?
Here, aic_bt_mode_value() hardcodes the firmware's baud rate patch to
1,500,000. However, in aic_bt_uart_probe(), the max-speed DT property is
read and configures the host UART speed. If the device tree specifies a
different speed, the host and controller will operate at different baud rates,
causing HCI communication to fail.
> diff --git a/drivers/bluetooth/btaic_uart.c b/drivers/bluetooth/btaic_uart.c
> --- a/drivers/bluetooth/btaic_uart.c
> +++ b/drivers/bluetooth/btaic_uart.c
[ ... ]
> static size_t aic_bt_receive_buf(struct serdev_device *serdev,
> const u8 *data, size_t count)
> {
> struct aic_bt_uart *uart = serdev_device_get_drvdata(serdev);
>
> uart->rx_skb = h4_recv_buf(&uart->hu, uart->rx_skb, data, count,
[ ... ]
> static int aic_bt_flush(struct hci_dev *hdev)
> {
[ ... ]
> kfree_skb(uart->rx_skb);
> uart->rx_skb = NULL;
[Severity: High]
Could this race with concurrent UART receives and cause a use-after-free?
When the HCI core invokes aic_bt_flush(), it frees uart->rx_skb. But the
serdev device is not closed until aic_bt_close(), meaning aic_bt_receive_buf()
could be executing simultaneously on another CPU, calling h4_recv_buf() on the
freed socket buffer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/178954773705.2.3446471521233620446@bedmex.com?part=3
next prev parent reply other threads:[~2026-09-17 2:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 8:35 [RFC PATCH bluetooth-next 0/3] Bluetooth: Add AIC8800D80 SDIO firmware loader and UART HCI Yanli Yang
2026-09-16 8:35 ` [RFC PATCH bluetooth-next 1/3] dt-bindings: vendor-prefixes: Add AIC Semiconductor Yanli Yang
2026-09-16 8:35 ` [RFC PATCH bluetooth-next 2/3] dt-bindings: net: bluetooth: Add AIC8800D80 Yanli Yang
2026-09-17 2:35 ` sashiko-bot
2026-09-16 8:35 ` [RFC PATCH bluetooth-next 3/3] Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport Yanli Yang
2026-09-17 2:43 ` sashiko-bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-09-16 8:12 [RFC PATCH bluetooth-next 0/3] Bluetooth: Add AIC8800D80 SDIO firmware loader and UART HCI Yanli Yang
2026-09-16 8:12 ` [RFC PATCH bluetooth-next 3/3] Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport Yanli Yang
2026-09-17 2:33 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260917024314.E65741F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yanli.yang@bedmex.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox