Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4428499pxb; Mon, 21 Feb 2022 21:19:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlWfkXyQyp9y+pXPdEJYWpLgi7vI5+O/cCS6WqdFu4JbocDDwrqOVtYev4QYSwaFZPzbr3 X-Received: by 2002:a17:902:a381:b0:14f:53a7:f340 with SMTP id x1-20020a170902a38100b0014f53a7f340mr21525987pla.158.1645507152203; Mon, 21 Feb 2022 21:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645507152; cv=none; d=google.com; s=arc-20160816; b=wUgxqJ/QS3Q8+3SiRMQdFEYuM3HjZg3S9l7tFzMBeOIG7GFku+L9c6obVvvml3LpKx uuJ1vk4Qh2Wmi/Tedy3KbZYpx2KnG21jP0qz5fRgh9oQ7bIstnfxWTQixZMbTQib2vNJ LHJxStJtp5o8wfc6nGeoS9lKCtYGe3hSdsXW6bwIDOD5lT2gd0OfMcsO9NnK/6QqWOPh PUvRTqNHnvT5aoMzZX8DBoms6lm1GpS6hxbVq/hAUnAP1vnTmbYXDs+xHzpFWJTrppoN X7ye320B8iKMkCw700E7iwjaw9pyT/J/w5vIUo8zpYA/Q18MvLUS4LC681L8wPGzl0kE GVBw== 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=EE/8/8dk2nVmRgAa29rnCwere/Dynoad789+WMpIj5g=; b=CypY86dEEverhgm3HlJRqq3VMduC9WGlZHFRGkQfJCyDK9IpaJ6bYTb/p1RqAOZudx 8+iyT+/SlWqVxUDLFM8QV32640xakkroOzNaiKK1CLaqcAuGXl9J57oMlBa5h/SKh7N7 tU5OiPgCVCPfTiYMVUwSp5epRzjjW6D7GqQmN+anqYGvYNGFLflAxicXUUOb8l4u+AMD NGYCmr5zirXrQwjg1K1dsfy6CZyK1IR+UxMz9O1t/WkbipGgVXyRlCXc6Xr5TeJd6QgX 0tENdh7HGRdfDJRiufAl0APhilY7eWg5U4VftvtO9RZdkltkM9Dcrw3o9Ia3MywKKISi LKrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hBY1ZGrX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u204si10795692pfc.294.2022.02.21.21.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:19:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hBY1ZGrX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 703B2EFF95; Mon, 21 Feb 2022 20:51:00 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352447AbiBUKFR (ORCPT + 99 others); Mon, 21 Feb 2022 05:05:17 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353531AbiBUJ5b (ORCPT ); Mon, 21 Feb 2022 04:57:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DECA913D02; Mon, 21 Feb 2022 01:26:40 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 79A8860F8C; Mon, 21 Feb 2022 09:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F3D3C340E9; Mon, 21 Feb 2022 09:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645435599; bh=s2FmeLYg45s5fZKmyXXZ8eeWA2DUYJTfH1h+F9G1sIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hBY1ZGrXmknCi4OcgzU5P8dQemFGSLCXoRnUlVxk7yQz8VwcoNF3/4Fmpeu7BSLFo QIYaHeFlMPP6BNI85oMuwym9SZm0KYSFar8h0L5x4Pdug5efVi6Sf4IDASF410NpYo N5nm4n17H0EYs/R3mYBQcU6RzSqSbZqZBR2IAxVM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charles Keepax , Mark Brown Subject: [PATCH 5.16 188/227] ASoC: wm_adsp: Correct control read size when parsing compressed buffer Date: Mon, 21 Feb 2022 09:50:07 +0100 Message-Id: <20220221084941.068129878@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084934.836145070@linuxfoundation.org> References: <20220221084934.836145070@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Charles Keepax commit a887f9c7a4d37a8e874ba8415a42a92a1b5139fc upstream. When parsing the compressed stream the whole buffer descriptor is now read in a single cs_dsp_coeff_read_ctrl; on older firmwares this descriptor is just 4 bytes but on more modern firmwares it is 24 bytes. The current code reads the full 24 bytes regardless, this was working but reading junk for the last 20 bytes. However commit f444da38ac92 ("firmware: cs_dsp: Add offset to cs_dsp read/write") added a size check into cs_dsp_coeff_read_ctrl, causing the older firmwares to now return an error. Update the code to only read the amount of data appropriate for the firmware loaded. Fixes: 04ae08596737 ("ASoC: wm_adsp: Switch to using wm_coeff_read_ctrl for compressed buffers") Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20220210172053.22782-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/codecs/wm_adsp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1448,7 +1448,8 @@ static int wm_adsp_buffer_parse_coeff(st int ret, i; for (i = 0; i < 5; ++i) { - ret = cs_dsp_coeff_read_ctrl(cs_ctl, &coeff_v1, sizeof(coeff_v1)); + ret = cs_dsp_coeff_read_ctrl(cs_ctl, &coeff_v1, + min(cs_ctl->len, sizeof(coeff_v1))); if (ret < 0) return ret;