Skip to content

Commit 0c09413

Browse files
nehebtiwai
authored andcommitted
ALSA: usb-audio: Use flexible allocation for Scarlett2 packets
Allocate Scarlett2 USB packets and request buffers with the flex allocation helpers for their trailing data arrays. Keep the computed packet sizes where they are still needed for USB transfer lengths. Assisted-by: Codex:GPT-5.5 Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://patch.msgid.link/20260519004935.627797-1-rosenp@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent cce8ec8 commit 0c09413

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

sound/usb/mixer_scarlett2.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,13 +2614,13 @@ static int scarlett2_usb(
26142614

26152615
struct scarlett2_usb_packet *req __free(kfree) = NULL;
26162616
size_t req_buf_size = struct_size(req, data, req_size);
2617-
req = kmalloc(req_buf_size, GFP_KERNEL);
2617+
req = kmalloc_flex(*req, data, req_size);
26182618
if (!req)
26192619
return -ENOMEM;
26202620

26212621
struct scarlett2_usb_packet *resp __free(kfree) = NULL;
26222622
size_t resp_buf_size = struct_size(resp, data, resp_size);
2623-
resp = kmalloc(resp_buf_size, GFP_KERNEL);
2623+
resp = kmalloc_flex(*resp, data, resp_size);
26242624
if (!resp)
26252625
return -ENOMEM;
26262626

@@ -2830,9 +2830,9 @@ static int scarlett2_usb_set_data_buf(
28302830
u8 data[];
28312831
} __packed *req;
28322832
int err;
2833-
int buf_size = struct_size(req, data, bytes);
2833+
size_t buf_size = struct_size(req, data, bytes);
28342834

2835-
req = kmalloc(buf_size, GFP_KERNEL);
2835+
req = kmalloc_flex(*req, data, bytes);
28362836
if (!req)
28372837
return -ENOMEM;
28382838

@@ -9646,7 +9646,7 @@ static long scarlett2_hwdep_write(struct snd_hwdep *hw,
96469646

96479647
/* Create and send the request */
96489648
len = struct_size(req, data, count);
9649-
req = kzalloc(len, GFP_KERNEL);
9649+
req = kzalloc_flex(*req, data, count);
96509650
if (!req)
96519651
return -ENOMEM;
96529652

0 commit comments

Comments
 (0)