From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: Re: [PATCH] drm/appletbdrm: Use kvzalloc for big allocations
Date: Thu, 23 Apr 2026 09:55:24 +1000 [thread overview]
Message-ID: <review-patch1-302f22e3-5390-4c0a-aa06-bfd02a3175c0@suse.de> (raw)
In-Reply-To: <302f22e3-5390-4c0a-aa06-bfd02a3175c0@suse.de>
Patch Review
**NAK — vmalloc memory cannot be used as a USB DMA transfer buffer.**
The allocation site:
```c
- appletbdrm_state->request = kzalloc(request_size, GFP_KERNEL);
+ appletbdrm_state->request = kvzalloc(request_size, GFP_KERNEL);
```
This buffer is subsequently passed to USB bulk transfer at `appletbdrm.c:449`:
```c
ret = appletbdrm_send_request(adev, &request->header, request_size);
```
Which calls `usb_bulk_msg()` at line 160:
```c
ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, adev->out_ep),
request, size, &actual_size, APPLETBDRM_BULK_MSG_TIMEOUT);
```
The USB HCD layer DMA-maps this buffer via `dma_map_single()` (`drivers/usb/core/hcd.c:1488`), and the DMA subsystem explicitly rejects vmalloc addresses (`include/linux/dma-mapping.h:513-515`). When `kvzalloc` falls back to vmalloc under memory pressure — the exact scenario this patch targets — the USB transfer will fail.
The free-side change is correct in isolation (matching `kvzalloc` with `kvfree`), but is moot given the allocation change is wrong:
```c
- kfree(appletbdrm_state->request);
+ kvfree(appletbdrm_state->request);
```
**Suggestion:** Replace `kvzalloc` with `kzalloc` using `__GFP_RETRY_MAYFAIL`:
```c
appletbdrm_state->request = kzalloc(request_size, GFP_KERNEL | __GFP_RETRY_MAYFAIL);
```
This tells the page allocator to try harder (compacting memory, reclaiming pages) before giving up, while keeping the allocation physically contiguous and safe for DMA. No change needed on the free side since `kfree` remains correct.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-04-22 23:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 12:17 [PATCH] drm/appletbdrm: Use kvzalloc for big allocations Sasha Finkelstein
2026-04-20 13:30 ` Thomas Zimmermann
2026-04-22 23:55 ` Claude review: " Claude Code Review Bot
2026-04-22 23:55 ` Claude Code Review Bot [this message]
2026-04-20 13:47 ` Thomas Zimmermann
2026-04-20 14:03 ` Aditya Garg
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-patch1-302f22e3-5390-4c0a-aa06-bfd02a3175c0@suse.de \
--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