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: firmware: qcom: Add a generic PAS service
Date: Mon, 09 Mar 2026 08:59:07 +1000	[thread overview]
Message-ID: <review-patch2-20260306105027.290375-3-sumit.garg@kernel.org> (raw)
In-Reply-To: <20260306105027.290375-3-sumit.garg@kernel.org>

Patch Review

This is the core abstraction patch and has the most significant issues.

**Race condition in ops_ptr access.** Every API function does a bare pointer check then dereference:

```c
int qcom_pas_init_image(u32 pas_id, const void *metadata, size_t size,
			struct qcom_pas_context *ctx)
{
	if (ops_ptr)
		return ops_ptr->init_image(ops_ptr->dev, pas_id,
					   metadata, size, ctx);
	return -ENODEV;
}
```

But `qcom_pas_ops_unregister()` can set `ops_ptr = NULL` concurrently. There's no RCU, no mutex, no refcounting — just `smp_store_release`/`smp_load_acquire` in the register/unregister/is_available paths. However, the actual API functions use bare `ops_ptr` reads without acquire semantics. This means a client could pass the `if (ops_ptr)` check, then the backend gets unregistered, and the `ops_ptr->init_image(...)` call dereferences freed/NULL memory. At minimum, all reads of `ops_ptr` in the API functions should use `smp_load_acquire`, and ideally an `srcu_read_lock` / refcount should protect the critical section.

**`qcom_pas_ops_register()` calls `qcom_pas_is_available()` which does `smp_load_acquire` but then the subsequent `smp_store_release` in the else branch is fine. However, two concurrent registrations are not protected — there's no lock, just a TOCTOU check:**

```c
void qcom_pas_ops_register(struct qcom_pas_ops *ops)
{
	if (!qcom_pas_is_available())
		smp_store_release(&ops_ptr, ops);
	else
		pr_err("qcom_pas: ops already registered\n");
}
```

**`qcom_scm_pas_auth_and_reset` doc comment typo** — the kernel-doc says `qcom_scm_pas_auth_and_reset` but the function is `qcom_pas_auth_and_reset` (line 663 in the new file).

**Return type mismatch on `get_rsc_table` callback.** The ops struct declares `void *(*get_rsc_table)(...)` but the public API `qcom_pas_get_rsc_table()` returns `struct resource_table *`. The implicit cast works but is inconsistent and should be explicit.

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-03-08 22:59 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06 10:50 [PATCH 00/14] firmware: qcom: Add OP-TEE PAS service support Sumit Garg
2026-03-06 10:50 ` [PATCH 01/14] arm64: dts: qcom: kodiak: Add EL2 overlay Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 02/14] firmware: qcom: Add a generic PAS service Sumit Garg
2026-03-06 11:15   ` Krzysztof Kozlowski
2026-03-06 15:40   ` Jeff Johnson
2026-03-06 15:49   ` Jeff Johnson
2026-03-06 19:47   ` Trilok Soni
2026-03-06 20:00     ` Trilok Soni
2026-03-06 22:00     ` Jeff Johnson
2026-03-06 22:16       ` Trilok Soni
2026-03-08 22:59   ` Claude Code Review Bot [this message]
2026-03-06 10:50 ` [PATCH 03/14] firmware: qcom_scm: Migrate to " Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 04/14] firmware: qcom: Add a PAS TEE service Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 05/14] remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 06/14] remoteproc: qcom_q6v5_mss: Switch " Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 07/14] soc: qcom: mdtloader: " Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 08/14] remoteproc: qcom_wcnss: " Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 09/14] remoteproc: qcom: Select QCOM_PAS_TEE service backend Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 10/14] drm/msm: Switch to generic PAS TZ APIs Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 11/14] media: qcom: " Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 12/14] net: ipa: " Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 13/14] wifi: ath12k: " Sumit Garg
2026-03-06 15:52   ` Jeff Johnson
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-06 10:50 ` [PATCH 14/14] firmware: qcom_scm: Remove SCM PAS wrappers Sumit Garg
2026-03-08 22:59   ` Claude review: " Claude Code Review Bot
2026-03-08 22:59 ` Claude review: firmware: qcom: Add OP-TEE PAS service support Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-12  6:27 [PATCH v2 00/15] " Sumit Garg
2026-03-12  6:27 ` [PATCH v2 02/15] firmware: qcom: Add a generic PAS service Sumit Garg
2026-03-13  4:26   ` 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-patch2-20260306105027.290375-3-sumit.garg@kernel.org \
    --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