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: Add batch allocation function and export API Date: Wed, 11 Feb 2026 17:15:49 +1000 Message-ID: In-Reply-To: <20260209061047.3881808-7-honglei1.huang@amd.com> References: <20260209061047.3881808-1-honglei1.huang@amd.com> <20260209061047.3881808-7-honglei1.huang@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Mailer: Claude Code Patch Reviewer Patch Review **Overview:** Main initialization function for batch allocations. **Issues:** 1. **Memory Leak on Error - Critical:** ```c + mem->user_ranges = kvcalloc(num_ranges, sizeof(struct user_range_info), + GFP_KERNEL); + if (!mem->user_ranges) { + ret = -ENOMEM; + goto out; + } ``` If allocation fails, `mem->user_ranges` is never freed before returning. Should `kvfree()` in error path. 2. **Integer Overflow - Critical:** ```c + range_end = ranges[i].start + ranges[i].size; ``` No overflow check. Should use `check_add_overflow()`. 3. **Missing Validation:** Should validate: - `num_ranges` has a maximum (prevent DoS) - Ranges don't overlap (could cause double-mapping issues) - Ranges are in ascending order (simplifies interval tree) 4. **Wrong User Address:** ```c + ret = amdgpu_ttm_tt_set_userptr(&bo->tbo, user_addr, 0); ``` `user_addr` is the GPU VA, not a CPU VA from any range. This seems incorrect. --- Generated by Claude Code Patch Reviewer