From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/amdkfd: Unify userptr cleanup and update paths Date: Wed, 11 Feb 2026 17:15:49 +1000 Message-ID: In-Reply-To: <20260209061047.3881808-8-honglei1.huang@amd.com> References: <20260209061047.3881808-1-honglei1.huang@amd.com> <20260209061047.3881808-8-honglei1.huang@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Mailer: Claude Code Patch Reviewer Patch Review **Overview:** Refactors cleanup to handle both single and batch allocations. **Issues:** 1. **Missing Lock - Critical:** ```c + if (mem->num_user_ranges > 0 && mem->user_ranges) { + for (i = 0; i < mem->num_user_ranges; i++) + interval_tree_remove(&mem->user_ranges[i].it_node, + &mem->user_ranges_itree); ``` Modifying the interval tree without holding any lock. This can race with concurrent MMU notifier callbacks. 2. **Use After Free - Critical:** ```c + if (mem->batch_notifier.mm) { + mmu_interval_notifier_remove(&mem->batch_notifier); + mem->batch_notifier.mm = NULL; + } + kvfree(mem->user_ranges); ``` After removing the notifier, a concurrent invalidation callback could still be running and accessing `mem->user_ranges`. Should ensure all callbacks are complete before freeing. 3. **Race Condition:** ```c + mem->user_ranges[i].valid = true; ``` Setting `valid` flag outside of `notifier_lock` can race with invalidation callbacks that clear it. --- Generated by Claude Code Patch Reviewer