From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796035804; b=kawVM6KMz10n2TuivX3WLFMCvOpYzvhMqlrWYrTfVBD09WfESRL42By8uPPWHx+sYVKv k7aBfWMXXqnUkccy9CA70WRVJZjSDwaoxkhK/uDr3YeX49c00ZbtUSc9B0B5NCr0Ginlq pWl2H3vmLaubAOVdfo71Fy+2lbS049aAcJCrGhZkQAJ1SX6qnhE5GMvQ2eVxclIsBNWtV n9VGgL2UMUhEX+X7XvY7sKJxRal8uge6hbcz8NEhxdFUnuhQRf9ya+vb8cY8qEHct2egU 8jLdGD+ug2misLWiNnrUf+tMwhE76OVXX0QR/NDHERiNz2g3S41u2wsW/LW53ZF1CIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796035804; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=/+XmYkeq8xIMjH3aEKAeSM89c2F8jw/vHQNpXa2c2qw=; b=fn1DpmrahfVcFDfVRrWpM5rIqTf3FetriL5ot5x2X00UUDqDW26cOQqzmvjOmWAFfVYM knZ2RW32rDtukXkQNYmpQsHtIqn2qhPqW9Mb43LhbeYdQd4AcHGfcTYpXtdKXfnv5d5GT GN/EKl/1niitdgcHULgUn1jsaFsQTdjRNEOxHnqWONY8ZnJSoM48YM8s+mNfxmvYCKCHX kQXA7EM2aWE6QmXCDkBSAbWf0Z7p/sB9shJLmaEa815jA63kbZcKiP66FZfACjmgRknbo B2sUWU/yocSIjmJKRDcn3tiq1TmzqCXZSM6zEXLvHA7w5oeu1KE1c5ON0lB50hxG/OQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0HUrCINN; arc=none smtp.remote-ip=209.85.216.52 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C171606A689 for ; Mon, 30 Nov 2026 10:50:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0C171606A689 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0HUrCINN Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-3b421e8d111so6661459a91.3 for ; Mon, 30 Nov 2026 02:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796035803; x=1796640603; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/+XmYkeq8xIMjH3aEKAeSM89c2F8jw/vHQNpXa2c2qw=; b=0HUrCINN6DDWsk/h/x0TCbR6Akmk/KH0HCiitP/hrosXF0C5Sr9qH+spW97L3ZH2JM YrVV9/u5/mgwCNe15ggAoht3yJ+2YhYUpQTYczan1OJRg/a3uKMp8r//5xjqemLzk/DL BrKrfJdd+HdCYRB7zXbKcaEhCEy7xMMF94gtRhuVstGiEEmlgs+omgfF1FKSnSTp9n+Z VDNe8I+6ODMN0K33LbEMb8xa7pwtiQ8c3VSkH5v5SHRkSwCp1wRtXs5TyKZQxCkMI7/n HDHt0Cniju59XIcyWeVmPgWPRBuTc8RrQwlytwDDZpay2oUvPX1SAX81gtlLAyauqHOq EJOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796035803; x=1796640603; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/+XmYkeq8xIMjH3aEKAeSM89c2F8jw/vHQNpXa2c2qw=; b=DHGtnNygEBd4u7LKDIJScM7imRJblhL2n3pTVZHmDG40ytEKxYkevDAfQim9ipxepr CJALTFvoZjFNuyWy8jUley39kQI3wDNVk7DBQab29cVEEz/kX/wsOth8cDxi8p03ACtX 4mPzMnjrj6H3VIZpFKY7LZlTpStAGEwAJxPTQ9wwXuGCs9NTPtwkmoxci0wrs10nMQ6S VNHKmemS2BSgeSVQDa95t0kgWmBgqOdOkQ1ms2KOMgpVKwczGwsZH1rV0NLQmCrsk/fu Tzxis/Fht4yeBlT35fptZyjmPL2BlAH0LzxfLqUt23wTtpVSMVFfN1P2zpQ8d0mwmE8N 6/8A== X-Forwarded-Encrypted: i=1; AL+hErFkTlQ5lclHnTOBzJNCAAzEv2aJnrqKp+pVpgqyGCIxsJavttxGXWgkNiKfgoWot7/GLCRfKqc=@vger.kernel.org X-Gm-Message-State: APuU4Z+I92rn5J886VPpQTSeuhDymew4s1+y9aXv9vnxXaYPpFzs7KBG 3OeSpYH1KHsVtYmpzDatBaZSbm2MFWLMX84VjjXO0s4HYYgFKfQBbhHp X-Gm-Gg: AZFdTZczfQPc6GITQVBtXOkqxhC8uf73kcM03kQ+rPMZ1V/dBuqtRz3Cs+lflIuh0gK CNqdMdVL4N3QgWSZR7N/7wlFgTezII7xG8MDRcMbqT6THLFobIj+1p/3nec/uMeDHW5giCAZT6H 55DEbcMRrd4NQvVQcrNx6WwP6Jn/X/d8Pymgi8gscr+Js+LLJmvfpI+I4tj5LQCmOtUCr0h9rtd g/oyiN0fVl79YKmFz9A48/itGA+SSTjRnUNxWAt3qiG4haB3fdGNzqQDNKtXaIIrG7w3kNxITsj 5Rt57Yxwce4TLOBeclaJsLhJV+8V6AsmZbd+GCZhn5zrA2Q8TVvyY/EfKiyH7pMpKlN9o2ALjkt x+fF13FBdJnFOKI87bDWS8E5uydJr5u9N9++mEuEK1oPVgjG67wQGBTFidU4DFoWrMkfN6Oxwls U2T5O+B1dXNDtqRs5kiQ8GVN/Iadjgd1LeSAHI0TdduhZfmGMmP+YIzbHZVFyHCEE7YycfR4XH1 KiKgY7jzRFPQ/qz/iJDyT1aDtv21Nmqy4T0WKkLWTL36hNIv6FHkX7CCHmn0hsmn0hob72sP6NN s8pTYO8hiEJ8QQjRJSCLgNrjr1u8LUqDYGFyjKV3Z+7QpJh3lmZ2lA== X-Received: by 2002:a17:90a:e7d0:b0:3a7:3474:b1ee with SMTP id 98e67ed59e1d1-3b41cb3276cmr32879142a91.60.1796035803330; Mon, 30 Nov 2026 02:50:03 -0800 (PST) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b41ad46ef5sm52391623a91.8.2026.11.30.02.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 02:50:02 -0800 (PST) From: Maoyi Xie To: Clemens Ladisch , Takashi Sakamoto Cc: Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 3/3] ALSA: oxfw: bound the stream format entries to the response length Date: Mon, 30 Nov 2026 18:49:49 +0800 Message-Id: <20261130104949.2216908-4-maoyixie.tju@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261130104949.2216908-1-maoyixie.tju@gmail.com> References: <20261130104949.2216908-1-maoyixie.tju@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit snd_oxfw_stream_parse_format() takes the number of two-byte entries of a stream format from format[4] and never sees the length of the response. A count of 254 or 255 can read past the 512-byte response buffer. An accepted format is copied into a buffer of the response length and parsed again later. A count that needs more than that length reads past the copy. Pass the length to snd_oxfw_stream_parse_format() and return -EIO when the entries do not fit. Keep the length of each copy for the later calls. Formats other than AM824 compound still get -ENXIO. Found with a CodeQL-based static analysis tool. Reproduced in a userspace harness under AddressSanitizer. Not tested on hardware. Fixes: 5cd1d3f47a63 ("ALSA: oxfw: Change the way to make PCM rules/constraints") Suggested-by: Takashi Sakamoto Cc: stable@vger.kernel.org Signed-off-by: Maoyi Xie --- I used an LLM to help write the harness and this patch. v2: Move the check into snd_oxfw_stream_parse_format() (Takashi Sakamoto). sound/firewire/oxfw/oxfw-pcm.c | 44 ++++++++++++++++++++++------ sound/firewire/oxfw/oxfw-proc.c | 6 ++-- sound/firewire/oxfw/oxfw-stream.c | 48 +++++++++++++++++++++++-------- sound/firewire/oxfw/oxfw.h | 3 ++ 4 files changed, 78 insertions(+), 23 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c index 774b8a763795..4b8417ba1227 100644 --- a/sound/firewire/oxfw/oxfw-pcm.c +++ b/sound/firewire/oxfw/oxfw-pcm.c @@ -10,7 +10,10 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { - u8 **formats = rule->private; + struct snd_pcm_substream *substream = rule->private; + struct snd_oxfw *oxfw = substream->private_data; + u8 **formats; + const unsigned int *lens; struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); const struct snd_interval *c = @@ -21,11 +24,19 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, struct snd_oxfw_stream_formation formation; int i, err; + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { + formats = oxfw->tx_stream_formats; + lens = oxfw->tx_stream_format_lens; + } else { + formats = oxfw->rx_stream_formats; + lens = oxfw->rx_stream_format_lens; + } + for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { if (formats[i] == NULL) continue; - err = snd_oxfw_stream_parse_format(formats[i], &formation); + err = snd_oxfw_stream_parse_format(formats[i], lens[i], &formation); if (err < 0) continue; if (!snd_interval_test(c, formation.pcm)) @@ -41,7 +52,10 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, static int hw_rule_channels(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { - u8 **formats = rule->private; + struct snd_pcm_substream *substream = rule->private; + struct snd_oxfw *oxfw = substream->private_data; + u8 **formats; + const unsigned int *lens; struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); const struct snd_interval *r = @@ -50,12 +64,20 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, int i, j, err; unsigned int count, list[SND_OXFW_STREAM_FORMAT_ENTRIES] = {0}; + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { + formats = oxfw->tx_stream_formats; + lens = oxfw->tx_stream_format_lens; + } else { + formats = oxfw->rx_stream_formats; + lens = oxfw->rx_stream_format_lens; + } + count = 0; for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { if (formats[i] == NULL) break; - err = snd_oxfw_stream_parse_format(formats[i], &formation); + err = snd_oxfw_stream_parse_format(formats[i], lens[i], &formation); if (err < 0) continue; if (!snd_interval_test(r, formation.rate)) @@ -77,7 +99,8 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, return snd_interval_list(c, count, list, 0); } -static void limit_channels_and_rates(struct snd_pcm_hardware *hw, u8 **formats) +static void limit_channels_and_rates(struct snd_pcm_hardware *hw, u8 **formats, + const unsigned int *lens) { struct snd_oxfw_stream_formation formation; int i, err; @@ -93,7 +116,7 @@ static void limit_channels_and_rates(struct snd_pcm_hardware *hw, u8 **formats) if (formats[i] == NULL) break; - err = snd_oxfw_stream_parse_format(formats[i], &formation); + err = snd_oxfw_stream_parse_format(formats[i], lens[i], &formation); if (err < 0) continue; @@ -111,6 +134,7 @@ static int init_hw_params(struct snd_oxfw *oxfw, { struct snd_pcm_runtime *runtime = substream->runtime; u8 **formats; + const unsigned int *lens; struct amdtp_stream *stream; int err; @@ -118,22 +142,24 @@ static int init_hw_params(struct snd_oxfw *oxfw, runtime->hw.formats = AM824_IN_PCM_FORMAT_BITS; stream = &oxfw->tx_stream; formats = oxfw->tx_stream_formats; + lens = oxfw->tx_stream_format_lens; } else { runtime->hw.formats = AM824_OUT_PCM_FORMAT_BITS; stream = &oxfw->rx_stream; formats = oxfw->rx_stream_formats; + lens = oxfw->rx_stream_format_lens; } - limit_channels_and_rates(&runtime->hw, formats); + limit_channels_and_rates(&runtime->hw, formats, lens); err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, - hw_rule_channels, formats, + hw_rule_channels, substream, SNDRV_PCM_HW_PARAM_RATE, -1); if (err < 0) goto end; err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, - hw_rule_rate, formats, + hw_rule_rate, substream, SNDRV_PCM_HW_PARAM_CHANNELS, -1); if (err < 0) goto end; diff --git a/sound/firewire/oxfw/oxfw-proc.c b/sound/firewire/oxfw/oxfw-proc.c index 260c60364f39..bcae6299ceca 100644 --- a/sound/firewire/oxfw/oxfw-proc.c +++ b/sound/firewire/oxfw/oxfw-proc.c @@ -30,7 +30,8 @@ static void proc_read_formation(struct snd_info_entry *entry, if (format == NULL) continue; - err = snd_oxfw_stream_parse_format(format, &formation); + err = snd_oxfw_stream_parse_format(format, oxfw->rx_stream_format_lens[i], + &formation); if (err < 0) continue; @@ -60,7 +61,8 @@ static void proc_read_formation(struct snd_info_entry *entry, if (format == NULL) continue; - err = snd_oxfw_stream_parse_format(format, &formation); + err = snd_oxfw_stream_parse_format(format, oxfw->tx_stream_format_lens[i], + &formation); if (err < 0) continue; diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 5e36d7153a7b..034bdaae09df 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -58,6 +58,7 @@ static int set_stream_format(struct snd_oxfw *oxfw, struct amdtp_stream *s, unsigned int rate, unsigned int pcm_channels) { u8 **formats; + const unsigned int *lens; struct snd_oxfw_stream_formation formation; enum avc_general_plug_dir dir; unsigned int len; @@ -65,15 +66,17 @@ static int set_stream_format(struct snd_oxfw *oxfw, struct amdtp_stream *s, if (s == &oxfw->tx_stream) { formats = oxfw->tx_stream_formats; + lens = oxfw->tx_stream_format_lens; dir = AVC_GENERAL_PLUG_DIR_OUT; } else { formats = oxfw->rx_stream_formats; + lens = oxfw->rx_stream_format_lens; dir = AVC_GENERAL_PLUG_DIR_IN; } /* Seek stream format for requirements. */ for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { - err = snd_oxfw_stream_parse_format(formats[i], &formation); + err = snd_oxfw_stream_parse_format(formats[i], lens[i], &formation); if (err < 0) return err; @@ -202,6 +205,7 @@ static int keep_resources(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { enum avc_general_plug_dir dir; u8 **formats; + const unsigned int *lens; struct snd_oxfw_stream_formation formation; struct cmp_connection *conn; int i; @@ -210,10 +214,12 @@ static int keep_resources(struct snd_oxfw *oxfw, struct amdtp_stream *stream) if (stream == &oxfw->rx_stream) { dir = AVC_GENERAL_PLUG_DIR_IN; formats = oxfw->rx_stream_formats; + lens = oxfw->rx_stream_format_lens; conn = &oxfw->in_conn; } else { dir = AVC_GENERAL_PLUG_DIR_OUT; formats = oxfw->tx_stream_formats; + lens = oxfw->tx_stream_format_lens; conn = &oxfw->out_conn; } @@ -227,7 +233,7 @@ static int keep_resources(struct snd_oxfw *oxfw, struct amdtp_stream *stream) if (formats[i] == NULL) break; - err = snd_oxfw_stream_parse_format(formats[i], &fmt); + err = snd_oxfw_stream_parse_format(formats[i], lens[i], &fmt); if (err < 0) return err; @@ -504,7 +510,7 @@ int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw, if (len < 3) err = -EIO; else - err = snd_oxfw_stream_parse_format(format, formation); + err = snd_oxfw_stream_parse_format(format, len, formation); } kfree(format); @@ -513,22 +519,26 @@ int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw, // command. Use the duplicated hard-coded format, instead. unsigned int rate; u8 *const *formats; + const unsigned int *lens; int i; err = avc_general_get_sig_fmt(oxfw->unit, &rate, dir, 0); if (err < 0) return err; - if (dir == AVC_GENERAL_PLUG_DIR_IN) + if (dir == AVC_GENERAL_PLUG_DIR_IN) { formats = oxfw->rx_stream_formats; - else + lens = oxfw->rx_stream_format_lens; + } else { formats = oxfw->tx_stream_formats; + lens = oxfw->tx_stream_format_lens; + } for (i = 0; (i < SND_OXFW_STREAM_FORMAT_ENTRIES); ++i) { if (!formats[i]) continue; - err = snd_oxfw_stream_parse_format(formats[i], formation); + err = snd_oxfw_stream_parse_format(formats[i], lens[i], formation); if (err < 0) continue; @@ -549,6 +559,7 @@ int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw, * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005 */ int snd_oxfw_stream_parse_format(const u8 *format, + unsigned int len, struct snd_oxfw_stream_formation *formation) { unsigned int i, e, channels, type; @@ -563,6 +574,10 @@ int snd_oxfw_stream_parse_format(const u8 *format, if ((format[0] != 0x90) || (format[1] != 0x40)) return -ENXIO; + /* The entries should be within the response. */ + if (len < 5 || len < 5 + format[4] * 2) + return -EIO; + /* check the sampling rate */ for (i = 0; i < ARRAY_SIZE(avc_stream_rate_table); i++) { if (format[2] == avc_stream_rate_table[i]) @@ -627,7 +642,7 @@ int snd_oxfw_stream_parse_format(const u8 *format, static int assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir, unsigned int pid, u8 *buf, unsigned int *len, - u8 **formats) + u8 **formats, unsigned int *lens) { struct snd_oxfw_stream_formation formation; unsigned int i, eid; @@ -664,7 +679,7 @@ assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir, /* parse and set stream format */ eid = 0; - err = snd_oxfw_stream_parse_format(buf, &formation); + err = snd_oxfw_stream_parse_format(buf, *len, &formation); if (err < 0) goto end; @@ -674,6 +689,7 @@ assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir, err = -ENOMEM; goto end; } + lens[eid] = *len; /* apply the format for each available sampling rate */ for (i = 0; i < ARRAY_SIZE(oxfw_rate_table); i++) { @@ -693,6 +709,7 @@ assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir, err = -ENOMEM; goto end; } + lens[eid] = *len; formats[eid][2] = avc_stream_rate_table[i]; } @@ -707,6 +724,7 @@ static int fill_stream_formats(struct snd_oxfw *oxfw, unsigned short pid) { u8 *buf, **formats; + unsigned int *lens; unsigned int len, eid = 0; struct snd_oxfw_stream_formation dummy; int err; @@ -715,10 +733,13 @@ static int fill_stream_formats(struct snd_oxfw *oxfw, if (buf == NULL) return -ENOMEM; - if (dir == AVC_GENERAL_PLUG_DIR_OUT) + if (dir == AVC_GENERAL_PLUG_DIR_OUT) { formats = oxfw->tx_stream_formats; - else + lens = oxfw->tx_stream_format_lens; + } else { formats = oxfw->rx_stream_formats; + lens = oxfw->rx_stream_format_lens; + } /* get first entry */ len = AVC_GENERIC_FRAME_MAXIMUM_BYTES; @@ -727,7 +748,7 @@ static int fill_stream_formats(struct snd_oxfw *oxfw, /* LIST subfunction is not implemented */ len = AVC_GENERIC_FRAME_MAXIMUM_BYTES; err = assume_stream_formats(oxfw, dir, pid, buf, &len, - formats); + formats, lens); goto end; } else if (err < 0) { dev_err(&oxfw->unit->device, @@ -746,7 +767,7 @@ static int fill_stream_formats(struct snd_oxfw *oxfw, } /* parse and set stream format */ - err = snd_oxfw_stream_parse_format(buf, &dummy); + err = snd_oxfw_stream_parse_format(buf, len, &dummy); if (err < 0) break; @@ -756,6 +777,7 @@ static int fill_stream_formats(struct snd_oxfw *oxfw, err = -ENOMEM; break; } + lens[eid] = len; /* get next entry */ len = AVC_GENERIC_FRAME_MAXIMUM_BYTES; @@ -814,6 +836,7 @@ int snd_oxfw_stream_discover(struct snd_oxfw *oxfw) if (format == NULL) continue; err = snd_oxfw_stream_parse_format(format, + oxfw->tx_stream_format_lens[i], &formation); if (err < 0) continue; @@ -842,6 +865,7 @@ int snd_oxfw_stream_discover(struct snd_oxfw *oxfw) if (format == NULL) continue; err = snd_oxfw_stream_parse_format(format, + oxfw->rx_stream_format_lens[i], &formation); if (err < 0) continue; diff --git a/sound/firewire/oxfw/oxfw.h b/sound/firewire/oxfw/oxfw.h index aeb83e1595b7..439182c50c8a 100644 --- a/sound/firewire/oxfw/oxfw.h +++ b/sound/firewire/oxfw/oxfw.h @@ -72,6 +72,8 @@ struct snd_oxfw { bool has_input; u8 *tx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES]; u8 *rx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES]; + unsigned int tx_stream_format_lens[SND_OXFW_STREAM_FORMAT_ENTRIES]; + unsigned int rx_stream_format_lens[SND_OXFW_STREAM_FORMAT_ENTRIES]; bool assumed; struct cmp_connection out_conn; struct cmp_connection in_conn; @@ -141,6 +143,7 @@ struct snd_oxfw_stream_formation { unsigned int midi; }; int snd_oxfw_stream_parse_format(const u8 *format, + unsigned int len, struct snd_oxfw_stream_formation *formation); int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir, -- 2.34.1