Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4441867rwb; Tue, 6 Sep 2022 07:35:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR6MNEH3It9pEBV3HkuQGiNFMmU/+iKVXB7IrjkqUOMk+eNrIxQpHUNwYfv4LO/3nhK4XDLS X-Received: by 2002:a17:903:189:b0:176:861a:d4d1 with SMTP id z9-20020a170903018900b00176861ad4d1mr16133052plg.154.1662474949328; Tue, 06 Sep 2022 07:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662474949; cv=none; d=google.com; s=arc-20160816; b=zSteWU2WfMup7q7pQlcggLbnUUw2A34Wgc9tzZ3dMbxASM8ngEWzeqYmX3G+0tpXnA oK0jLQ4yRoHAMr8+0fefyA8+B4UVMIzN+HTV8hQxHmrbWBc3GNOiwq3z21AeWtb0Ixzf bw2A1jpMGl12oMYOk75DlwKY8xkxaIgygmEEWZ2HUkUKPg5X14DcJ7OHul+YQDhKCEgm +EPSVKEvH0/i1MVJA+pEKxzup+3ppQbP/2Nmr2uxGRlKPwViaHAOq4wctRj3Lz8D0Z85 Dd1CNVGzU5X3j1Hjqz3vgfIHPb46DhP7EzphfYyFlJuMb/kJKW+nht79WdihPqgGDU3p FDxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZC/3KI8tv/QbDqHQrhbxDxiyznJvme4QrF/tfZd2Irc=; b=vc5jkc4Mh+eYRMsJWahmUb0h1KKpZfp2E8sIpKiSKDi5pOKo+sKKANu82hSgVlNnkv v1Gjtk3zpw50YUdEJSdtWGtZcWtB6GXvbjwLLsk1pwLM14gAtWVrvqtszJNwg8p3gwlr 54whXEWN11U644fQI+YqiRkLu3edtgjz7sBq8I0UP+8nFoC1L1S07rDZCI6BRjhVUpGG mCRX2gPISb8d/22iYBckPcChpHn/kAoCUvKKU6FqiiamDYvt0JvvbDf0ksLDqHirC9a7 uutE2IaCbckvt6x4THmPA8sRpEfZjstljEU2Iopuy+DTTqZj8bhepgxRCPOz250H1WwU ouJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ICsyXcfG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w2-20020a170902904200b00176806795b7si9436137plz.351.2022.09.06.07.35.36; Tue, 06 Sep 2022 07:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ICsyXcfG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239642AbiIFNcP (ORCPT + 99 others); Tue, 6 Sep 2022 09:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239033AbiIFNcH (ORCPT ); Tue, 6 Sep 2022 09:32:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C018753AC; Tue, 6 Sep 2022 06:32:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B8D11B818C2; Tue, 6 Sep 2022 13:32:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D31EAC433D6; Tue, 6 Sep 2022 13:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471124; bh=PUGgoVZZTJScvvtPoB/2rewiBTZxS5R7xBg7g7fXaeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ICsyXcfGQLnxo8x72dWh32sWRKhKL6X8F/hHLrrKexu4aXpWzvmLqRQxxAAEOKJY4 aa4RIzCQjjqdYWwL/Ihz32z1NP4OevgTVSRzvsCHF5X/ICuv/k54wRpBvzZPzg1Bbh SQ+9zl6CRsKPzeB9Bx3WPKmVfZc+HLtJubwP7HRk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Ujfalusi , Pierre-Louis Bossart , Jaska Uimonen , Takashi Iwai , Sasha Levin Subject: [PATCH 5.10 10/80] ALSA: hda: intel-nhlt: Correct the handling of fmt_config flexible array Date: Tue, 6 Sep 2022 15:30:07 +0200 Message-Id: <20220906132817.359003122@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Ujfalusi [ Upstream commit 2e6481a3f3ee6234ce577454e1d88aca55f51d47 ] The struct nhlt_format's fmt_config is a flexible array, it must not be used as normal array. When moving to the next nhlt_fmt_cfg we need to take into account the data behind the ->config.caps (indicated by ->config.size). Fixes: a864e8f159b13 ("ALSA: hda: intel-nhlt: verify config type") Signed-off-by: Peter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Jaska Uimonen Link: https://lore.kernel.org/r/20220823122405.18464-1-peter.ujfalusi@linux.intel.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/hda/intel-nhlt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c index 5e04fedaec49e..8714891f50b0a 100644 --- a/sound/hda/intel-nhlt.c +++ b/sound/hda/intel-nhlt.c @@ -55,16 +55,22 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) /* find max number of channels based on format_configuration */ if (fmt_configs->fmt_count) { + struct nhlt_fmt_cfg *fmt_cfg = fmt_configs->fmt_config; + dev_dbg(dev, "found %d format definitions\n", fmt_configs->fmt_count); for (i = 0; i < fmt_configs->fmt_count; i++) { struct wav_fmt_ext *fmt_ext; - fmt_ext = &fmt_configs->fmt_config[i].fmt_ext; + fmt_ext = &fmt_cfg->fmt_ext; if (fmt_ext->fmt.channels > max_ch) max_ch = fmt_ext->fmt.channels; + + /* Move to the next nhlt_fmt_cfg */ + fmt_cfg = (struct nhlt_fmt_cfg *)(fmt_cfg->config.caps + + fmt_cfg->config.size); } dev_dbg(dev, "max channels found %d\n", max_ch); } else { -- 2.35.1