From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: bus: mhi: Capture DDR training data using command mode
Date: Mon, 09 Mar 2026 08:09:01 +1000 [thread overview]
Message-ID: <review-patch7-20260307-sahara_protocol_new_v2-v2-7-29dc748b5e9c@oss.qualcomm.com> (raw)
In-Reply-To: <20260307-sahara_protocol_new_v2-v2-7-29dc748b5e9c@oss.qualcomm.com>
Patch Review
This is the largest and most complex patch (320 lines added). It has several significant issues:
- **Comparison of unsigned with < 0 is always false:**
```c
+ if (le32_to_cpu(context->rx->length) != SAHARA_COMMAND_EXEC_RESP_LENGTH ||
+ le32_to_cpu(context->rx->command_execute_resp.response_length) < 0) {
```
`le32_to_cpu` returns `u32`, which is unsigned and can never be `< 0`. This check is dead code.
- **`sahara_command_execute_resp` calls both `sahara_command_execute_data` AND `sahara_command_execute` for the command ID list case:**
```c
sahara_command_execute_data(context, client_cmd);
if (client_cmd == SAHARA_EXEC_CMD_GET_COMMAND_ID_LIST) {
sahara_command_execute(context, SAHARA_EXEC_CMD_GET_TRAINING_DATA);
return;
}
```
This sends EXECUTE_DATA for the command list and then immediately sends another EXECUTE for training data, without waiting for the command list data to arrive. This seems like a race -- two TX packets are queued back-to-back without processing the response from the first.
- **GFP_KERNEL allocation from interrupt context.** `sahara_ctrl_trng_get()` is called from `sahara_mhi_dl_xfer_cb()` (the DL transfer callback), which runs in interrupt/softirq context. Inside `sahara_ctrl_trng_get()`:
```c
ct = devres_alloc(sahara_ctrl_trng_release, sizeof(*ct), GFP_KERNEL);
```
`GFP_KERNEL` can sleep, which is invalid in atomic context. Additionally, `mutex_init` and `devres_add` may also have issues here.
- **Race conditions on shared state.** Fields like `context->is_cmd_mode`, `context->receiving_trng_data`, `context->trng_rcvd`, etc. are accessed from both workqueue context and the DL callback (interrupt context) without any synchronization primitives. The `ct->lock` mutex protects the controller-scoped data but a mutex cannot be used from interrupt context -- `mutex_lock()` in `sahara_mhi_dl_xfer_cb` can sleep.
- **`kzalloc(resp_len, GFP_KERNEL)` with device-controlled size.** The `resp_len` comes directly from the device packet. There's no upper bound check, so a malicious or buggy device could request an arbitrarily large allocation:
```c
ct->data = kzalloc(resp_len, GFP_KERNEL);
```
Consider adding a sanity check on `resp_len`.
- **Accessing `ct->data` outside the lock:**
```c
mutex_unlock(&ct->lock);
if (!ct->data) { // <-- outside lock
```
After dropping the lock, another thread could modify `ct->data`. The NULL check should be inside the critical section.
- **`sahara_ctrl_trng_release` takes a mutex in devres release**, which might run during device teardown. Setting fields after `kfree` under the lock serves no purpose since the structure itself is being freed.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-03-08 22:09 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 11:41 [PATCH v2 0/9] Qualcomm Sahara protocol enhancements Kishore Batta
2026-03-07 11:41 ` [PATCH v2 1/9] Add documentation for Sahara protocol Kishore Batta
2026-03-07 19:50 ` kernel test robot
2026-03-08 22:09 ` Claude review: " Claude Code Review Bot
2026-03-07 11:41 ` [PATCH v2 2/9] bus: mhi: Move sahara protocol driver under drivers/bus/mhi Kishore Batta
2026-03-08 22:09 ` Claude review: " Claude Code Review Bot
2026-03-07 11:41 ` [PATCH v2 3/9] bus: mhi: Match devices exposing the protocol on the SAHARA channel Kishore Batta
2026-03-08 22:09 ` Claude review: " Claude Code Review Bot
2026-03-07 11:41 ` [PATCH v2 4/9] bus: mhi: Centralize firmware image table selection at probe time Kishore Batta
2026-03-08 8:56 ` kernel test robot
2026-03-08 9:27 ` kernel test robot
2026-03-08 22:09 ` Claude review: " Claude Code Review Bot
2026-03-07 11:41 ` [PATCH v2 5/9] bus: mhi: Add QDU100 firmware image table Kishore Batta
2026-03-08 22:09 ` Claude review: " Claude Code Review Bot
2026-03-07 11:41 ` [PATCH v2 6/9] bus: mhi: Load DDR training data using per-device serial number Kishore Batta
2026-03-08 22:09 ` Claude review: " Claude Code Review Bot
2026-03-07 11:41 ` [PATCH v2 7/9] bus: mhi: Capture DDR training data using command mode Kishore Batta
2026-03-08 22:09 ` Claude Code Review Bot [this message]
2026-03-07 11:41 ` [PATCH v2 8/9] bus: mhi: Expose DDR training data via controller sysfs Kishore Batta
2026-03-08 22:09 ` Claude review: " Claude Code Review Bot
2026-03-07 11:41 ` [PATCH v2 9/9] Documentation: ABI: Add sysfs ABI documentation for DDR training data Kishore Batta
2026-03-08 22:09 ` Claude review: " Claude Code Review Bot
2026-03-08 22:08 ` Claude review: Qualcomm Sahara protocol enhancements Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-03-10 7:21 [PATCH v3 0/9] " Kishore Batta
2026-03-10 7:22 ` [PATCH v3 7/9] bus: mhi: Capture DDR training data using command mode Kishore Batta
2026-03-11 3:35 ` Claude review: " Claude Code Review Bot
2026-03-19 6:31 [PATCH v4 0/9] Qualcomm Sahara protocol enhancements Kishore Batta
2026-03-19 6:31 ` [PATCH v4 7/9] bus: mhi: Capture DDR training data using command mode Kishore Batta
2026-03-21 18:44 ` Claude review: " Claude Code Review 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=review-patch7-20260307-sahara_protocol_new_v2-v2-7-29dc748b5e9c@oss.qualcomm.com \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.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