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/gem-shmem: Test for existence of page in mmap fault handler Date: Wed, 11 Feb 2026 17:04:33 +1000 Message-ID: In-Reply-To: <20260209133241.238813-3-tzimmermann@suse.de> References: <20260209133241.238813-1-tzimmermann@suse.de> <20260209133241.238813-3-tzimmermann@suse.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Mailer: Claude Code Patch Reviewer Patch Review **Review:** This adds important defensive programming by checking for NULL pages: ```c + page = pages[page_offset]; + if (drm_WARN_ON_ONCE(dev, !page)) + goto out; ``` **Concern 1 - Error path behavior:** The patch changes the default return value to `VM_FAULT_SIGBUS`: ```c - vm_fault_t ret; + vm_fault_t ret = VM_FAULT_SIGBUS; ``` This means if the function takes an early error path, it returns SIGBUS. However, looking at the existing error cases: ```c if (page_offset >= num_pages || drm_WARN_ON_ONCE(dev, !shmem->pages) || shmem->madv < 0) goto out; ``` **Question:** Is VM_FAULT_SIGBUS the correct return for all these cases? The `madv < 0` case indicates the object was marked as "don't need", which traditionally should return VM_FAULT_SIGBUS. But are the other cases correctly signaling a bus error to userspace? **Concern 2 - Variable declaration style:** ```c + pgoff_t page_offset = vmf->pgoff - vma->vm_pgoff; /* page offset within VMA */ ``` The comment is helpful, but mixing initialized and uninitialized variable declarations: ```c + vm_fault_t ret = VM_FAULT_SIGBUS; + struct page **pages = shmem->pages; + pgoff_t page_offset = vmf->pgoff - vma->vm_pgoff; + struct page *page; + unsigned long pfn; ``` This is acceptable but slightly inconsistent with kernel style which often groups declarations. **Concern 3 - WARN_ON vs error handling:** ```c + if (drm_WARN_ON_ONCE(dev, !page)) + goto out; ``` This uses `drm_WARN_ON_ONCE` which is appropriate for "should never happen" conditions. However, **when can `page` be NULL?** If this is a legitimate error condition (e.g., race with page eviction), WARN might be too noisy. If it's truly never supposed to happen, this is correct. **Verdict:** ⚠ Needs clarification on the NULL page scenario and whether WARN is appropriate --- --- Generated by Claude Code Patch Reviewer