From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796035804; b=licDwu12vjnPcYgaHiYymDV8Q5vlqLS1DDBsfCkYieDS0nWZt6+dYQeZoTqRWzU50cDf 3VAkqvF+qvHzB6L6NhB3uND9ifo6j1RfOLnTEBpu/6DC4ZbKLevRHnlTHyl81yxTbfbMh +wdFhnHt9h9EJcwz54bJ21HHgzRCbavwvF3bnomr0sVHSKLJ4vF2ZcVhVikZqCdbj3riB cPQoq/InUKS9ocI0svCh+14IveKvv8/P515yCBdmWnlVhHvXCP2n4YHrbMxgLD/RaT9GF 6xC71Aavl1ouWB20200qcPSAGiDmUei2K5sOIoEOcwPUCI1rpNVz7DcZTViDRuMUWiQ== 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=m3qvg0zegacwsOgnFIWFG9zQMiUm59HHsNBoly/yjCqRQfFn1j9/BENCb06mATp8nIVR ipIg0kusXGZKjCL2MSGOpzPWBKuJ6dp36AaiGT8bi8h4Hd6ZxX32ZZzmx3dmPggBF1gbj 3Y8txzSoKHvsmOxO3NyQXYWmtU90pIOYKBIlI90i+MPAPx2MnSDkA1jVBMP3UE8L5taW+ 9abduxrTIIzdBl8OulWvX1aNdlWNwHaRZAdvGif6+8BA3S7rfTytO69kV9qy9LKpFa3GU 1eHtRc0ZbxZjccYNursOXiUCDxCLbCezp87PJrCEtQU5DKSXmM052VMIWFOjvH0ITPA== 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.215.178 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 244E7606A688 for ; Mon, 30 Nov 2026 10:50:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 244E7606A688 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-pg1-f178.google.com with SMTP id 41be03b00d2f7-cdb684859cbso5973756a12.1 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=Mi6AFkUe3xUQqVCsFSChec5z2BgzhmTPBWGvAEN1zO/9S8imKWIlrKBYDy8cHslTRK /L5WfFolBRP/XG/oi8H66KSrtYDgbKM9Stt5KmyOSocVNy7dOCmytaFbeQCA0hnEVfuw g7Ckua0RBvx2IKkaaeTSlY1A1+xnbuG/bIfpzxTkiHKuetY4NWOFZT8ZhTxi+iGrrTSh +XvI8Iuk+GjMbV8LswYmIGwKZBEFpSaIWkkwmy1XmRO6giUk5p6vM2EeJQC9uj8zjav/ XTPvqgTxksTxYEJYje1jb4pNloQA2Dnose8xJ4QzwfY2tvR6ml++LMFKv2LZy/WdHFcY vVFA== X-Forwarded-Encrypted: i=1; AL+hErHYYGwgyV6xO1Q7mxuBnL6bw7myIEdlosiyzTtOTzd5Hqc2HHxHbvQCyF5IRSusPk+myVGzxmi92EIWJg==@vger.kernel.org X-Gm-Message-State: APuU4Z/nqoTHU0mh4Ejqdhn9Ot+qxOeApbPufnlpnMBjo7UawS4yZUK7 E9ozEpWzWcW+WzHroc7mx8D8WB93yLJUkR2Y38Q346sPZNoyxvQjpxlg X-Gm-Gg: AZFdTZfqhegCNqJ4yoOM/oEOWFPN+3heJ8icNw6DN/5i5ykd1XGCNxZAPE8OSRpupp7 xeZaDdlu3A2vDlyhIDnraZ4Y41lIGHS8LPpdEcGLb1GKFC3ldFSeYZs660VGMFEqkZjQ6nvPDw+ TXNMsXqXo2psSeEOR3OPAs2eSveu+HWcfzRh6aUkl4pP6XueVZ+sIFDbWEMEwE1g1IzHeuli94Y q9lcG3CPy78ysy7YwsU9MXMF25uJFyL6+Cxp1vRhfeJyShEchc+LH8zLKvlJSw2YduQHKlLbb+N pR3f7h2e/fM1plWv8vcwkKgduWlemCkdtS0E7tI/wXRtpijtHzBKcCHWc8Dx+oFOoAA/vOgz2LE 2CwnCexbUeEteg2ckjgNw/f2uV2zmOlKi9liF1vu5LqkRmC01bXVPolfx+iwPIuPLIuxJIQzqNf kmP/W1QYOYcO0Im7osoQU1GhYUskT1qrAr5rilmzkykiBZZAoOLooB3ouSbKml9jJ2RkwMQiTlD Z6nmO7WDNf5QH4zWwueDdIoxVZphaXaJVG1buhLxIEnA7wgFefm0E0LRKIETQ/cwcK5xr402Im3 Iy5Tvj6r1C06EDT5HwpYPbQzakthqKmB1S+qWzE0dkfPuzW9vFS8Jw== 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: linux-sound@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