]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: usb-audio: Use flexible allocation for Scarlett2 packets
authorRosen Penev <rosenp@gmail.com>
Tue, 19 May 2026 00:49:35 +0000 (17:49 -0700)
committerTakashi Iwai <tiwai@suse.de>
Tue, 19 May 2026 06:04:15 +0000 (08:04 +0200)
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>
sound/usb/mixer_scarlett2.c

index 89dbb403d25534c06939bb5e87336bb04a2061cf..7c43ca51938e30ccb64d0d02b5469c913bad131a 100644 (file)
@@ -2614,13 +2614,13 @@ static int scarlett2_usb(
 
        struct scarlett2_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 scarlett2_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;
 
@@ -2830,9 +2830,9 @@ static int scarlett2_usb_set_data_buf(
                u8 data[];
        } __packed *req;
        int err;
-       int buf_size = struct_size(req, data, bytes);
+       size_t buf_size = struct_size(req, data, bytes);
 
-       req = kmalloc(buf_size, GFP_KERNEL);
+       req = kmalloc_flex(*req, data, bytes);
        if (!req)
                return -ENOMEM;
 
@@ -9646,7 +9646,7 @@ static long scarlett2_hwdep_write(struct snd_hwdep *hw,
 
        /* Create and send the request */
        len = struct_size(req, data, count);
-       req = kzalloc(len, GFP_KERNEL);
+       req = kzalloc_flex(*req, data, count);
        if (!req)
                return -ENOMEM;