From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: pvr: acquire vm_ctx->lock before mapping memory to GPU VM Date: Thu, 23 Apr 2026 08:14:32 +1000 Message-ID: In-Reply-To: <20260421175228.1928742-1-zhengxingda@iscas.ac.cn> References: <20260421175228.1928742-1-zhengxingda@iscas.ac.cn> <20260421175228.1928742-1-zhengxingda@iscas.ac.cn> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **Bug: double `mutex_unlock` on the success path** After the patch, `pvr_vm_map()` looks like this (lines 750=E2=80=93764): ```c mutex_lock(&vm_ctx->lock); // line 750 err =3D drm_gpuvm_exec_lock(&vm_exec); if (err) goto err_cleanup; err =3D pvr_vm_bind_op_exec(&bind_op); drm_gpuvm_exec_unlock(&vm_exec); mutex_unlock(&vm_ctx->lock); // line 758 =E2=80=94 first unlock err_cleanup: pvr_vm_bind_op_fini(&bind_op); mutex_unlock(&vm_ctx->lock); // line 762 =E2=80=94 SECOND unlock! return err; ``` On the **success path** (no error), execution flows: 1. `mutex_lock` at line 750 2. `mutex_unlock` at line 758 (after `drm_gpuvm_exec_unlock`) 3. Falls through to `err_cleanup` 4. `mutex_unlock` at line 762 =E2=80=94 **double unlock**, which is undefin= ed behavior on a non-recursive mutex and will trigger `DEBUG_LOCKS_WARN_ON`= with lockdep enabled. On the **error path** (`drm_gpuvm_exec_lock` fails), it correctly jumps to = `err_cleanup` and unlocks once. **Fix:** The success path needs to skip the second unlock. The cleanest app= roaches would be either: 1. Replace the `mutex_unlock` + fall-through with a `goto` past `err_cleanu= p`: ```c drm_gpuvm_exec_unlock(&vm_exec); err_cleanup: pvr_vm_bind_op_fini(&bind_op); mutex_unlock(&vm_ctx->lock); return err; ``` This mirrors the existing pattern for `drm_gpuvm_exec_unlock` where it unlo= cks before the label but the `_fini` is shared. Just move the single `mutex= _unlock` to the shared cleanup block. 2. Or, use `goto` to skip the second unlock on the success path. **Minor observation on the commit message:** - "NULL deference" should be "NULL dereference" (typo). - "all occurences" should be "all occurrences". - The commit message claims "all occurrences of `drm_gpuva_find*()` is alre= ady guarded by `vm_ctx->lock`," which is accurate based on the code at line= s 865=E2=80=93867 and 891=E2=80=93898. The rationale is sound =E2=80=94 the= issue is purely in the implementation. **Verdict:** The motivation is correct and the fix is needed, but this patc= h **must not be applied as-is** due to the double-unlock bug. It needs a v2. --- Generated by Claude Code Patch Reviewer