Skip to contentSkip to conversation

ALSA: usb-audio: Use flexible allocation for FCP packets

PATCH Applied Rosen Penev 2 participants 2 messages May 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: usb-audio: Use flexible allocation for FCP packets

Allocate FCP request and response packets with kmalloc_flex() for the trailing packet data instead of passing the computed struct size directly to kmalloc().

Keep the computed packet sizes for the USB transfer length checks.

Assisted-by Codex:GPT-5.5
---
 sound/usb/fcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/fcp.c +2 -2
index 0fc4d063c48a..ea746bdb36ff 100644
@@ -191,13 +191,13 @@ static int fcp_usb(struct usb_mixer_interface *mixer, u32 opcode,
 
 	struct fcp_usb_packet *req __free(kfree) = NULL;
 	size_t req_buf_size = struct_size(req, data, req_size);
-	req = kmalloc(req_buf_size, GFP_KERNEL);
+	req = kmalloc_flex(*req, data, req_size);
 	if (!req)
 		return -ENOMEM;
 
 	struct fcp_usb_packet *resp __free(kfree) = NULL;
 	size_t resp_buf_size = struct_size(resp, data, resp_size);
-	resp = kmalloc(resp_buf_size, GFP_KERNEL);
+	resp = kmalloc_flex(*resp, data, resp_size);
 	if (!resp)
 		return -ENOMEM;
 
Signature · 1 line
2.54.0
Applied
#1 lore raw
Quoted 9 lines · Rosen Penev

Allocate FCP request and response packets with kmalloc_flex() for the trailing packet data instead of passing the computed struct size directly to kmalloc().

Keep the computed packet sizes for the USB transfer length checks.

Assisted-by Codex:GPT-5.5

Applied to for-next branch. Thanks.

Takashi