public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
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: Sun, 22 Mar 2026 04:44:35 +1000	[thread overview]
Message-ID: <review-patch7-20260319-sahara_protocol_new_v2-v4-7-47ad79308762@oss.qualcomm.com> (raw)
In-Reply-To: <20260319-sahara_protocol_new_v2-v4-7-47ad79308762@oss.qualcomm.com>

Patch Review

This is the most complex patch and has the most serious issues.

**Issues:**

- **Bug: Unsigned comparison always false** at `sahara.c:706`:
  ```c
  le32_to_cpu(context->rx->command_execute_resp.response_length) < 0
  ```
  `le32_to_cpu()` returns `u32`. This comparison is always false and provides no validation.

- **Bug: Sleeping in atomic context.** `sahara_mhi_dl_xfer_cb()` (line 1367) is an MHI transfer callback that can run in tasklet/softirq context. It calls:
  - `sahara_ctrl_trng_get()` → `devres_alloc(..., GFP_KERNEL)` — may sleep
  - `mutex_lock(&ct->lock)` — may sleep
  
  Both are illegal in atomic context.

- **Bug: Unbounded `kzalloc` from device-controlled value** at `sahara.c:735`:
  ```c
  ct->data = kzalloc(resp_len, GFP_KERNEL);
  ```
  `resp_len` comes directly from the device with no upper bound. A malicious/buggy device could cause an enormous allocation. Add a sanity cap.

- **Bug: `ct->data` checked outside the lock** at `sahara.c:741`:
  ```c
  mutex_unlock(&ct->lock);
  if (!ct->data) { ...
  ```
  After releasing the lock, `ct->data` could be freed by another thread. Move the NULL check inside the critical section.

- **Data races**: `context->is_cmd_mode`, `receiving_trng_data`, `trng_rcvd`, `trng_size`, `trng_nbuf` are accessed from both the DL callback (potentially tasklet context) and the work queue without any locking or memory barriers.

- **TX buffer reuse**: At `sahara.c:716-719`, `sahara_command_execute_data()` and `sahara_command_execute()` both write to `context->tx[0]` and queue it. The first may not have been consumed by MHI before the second overwrites it.

- **Missing `cancel_work_sync(&context->read_data_work)`** in the remove path (line 1347-1357). Only `fw_work`, `dump_work`, and `cmd_work` are cancelled.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-03-21 18:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19  6:31 [PATCH v4 0/9] Qualcomm Sahara protocol enhancements Kishore Batta
2026-03-19  6:31 ` [PATCH v4 1/9] Add documentation for Sahara protocol Kishore Batta
2026-03-21 18:44   ` Claude review: " Claude Code Review Bot
2026-03-19  6:31 ` [PATCH v4 2/9] bus: mhi: Move sahara protocol driver under drivers/bus/mhi Kishore Batta
2026-03-21 18:44   ` Claude review: " Claude Code Review Bot
2026-03-19  6:31 ` [PATCH v4 3/9] bus: mhi: Match devices exposing the protocol on the SAHARA channel Kishore Batta
2026-03-21 18:44   ` Claude review: " Claude Code Review Bot
2026-03-19  6:31 ` [PATCH v4 4/9] bus: mhi: Centralize firmware image table selection at probe time Kishore Batta
2026-03-21 18:44   ` Claude review: " Claude Code Review Bot
2026-03-19  6:31 ` [PATCH v4 5/9] bus: mhi: Add QDU100 variant and image_id firmware fallback Kishore Batta
2026-03-21 18:44   ` Claude review: " Claude Code Review Bot
2026-03-19  6:31 ` [PATCH v4 6/9] bus: mhi: Load DDR training data using per-device serial number Kishore Batta
2026-03-21 18:44   ` Claude review: " Claude Code Review Bot
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 Code Review Bot [this message]
2026-03-19  6:31 ` [PATCH v4 8/9] bus: mhi: Expose DDR training data via controller sysfs Kishore Batta
2026-03-21 18:44   ` Claude review: " Claude Code Review Bot
2026-03-19  6:31 ` [PATCH v4 9/9] Documentation: ABI: Add sysfs ABI documentation for DDR training data Kishore Batta
2026-03-21 18:44   ` Claude review: " Claude Code Review Bot
2026-03-21 18:44 ` 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-07 11:41 [PATCH v2 0/9] Qualcomm Sahara protocol enhancements Kishore Batta
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 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-20260319-sahara_protocol_new_v2-v4-7-47ad79308762@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