From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 66013C43217 for ; Thu, 13 Oct 2022 00:25:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 908F153F8; Thu, 13 Oct 2022 02:24:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 908F153F8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1665620714; bh=Af8giS2+ZfpdZxS5MHM8Plt2o38OtS7fPeNrZbHoCb4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MPcEkMrujPk8LA88pH1kcgPiXlzwI+2iSpKquRUCoOgD5WOQF8R0Jq+jDXRfFkl6u S1xFW8r281x1wpN4Vk6QdFslexgneh05zrn1nVIcpBxPLfaFFFwkZtOS7Pvt1XIEtL 1+wt4VbWKpMN3lSESmpdckEIJdrr45PM22BI6N80= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 32F47F80246; Thu, 13 Oct 2022 02:24:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 92701F80132; Thu, 13 Oct 2022 02:24:23 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DA0CFF80132 for ; Thu, 13 Oct 2022 02:24:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DA0CFF80132 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q/f68lHg" 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 1DFD5B81CF7; Thu, 13 Oct 2022 00:24:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21A32C433C1; Thu, 13 Oct 2022 00:24:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665620655; bh=Af8giS2+ZfpdZxS5MHM8Plt2o38OtS7fPeNrZbHoCb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q/f68lHg47fS8OBF/c1oED9rcZir5yso1sW6zvyVN/QyE6r3brKA03aFWdx8N8BUk 87DK+z/2gc1Q9ZLZPWoQF3AvHTw/xasy/fdfA0wxJ86ExMboBX7M8G1KLTNmTMzI0b FSuUvuDljJSp+vJ2rrsbanNWlK4TZ7gj2JxK8EhybA3qVLue93phK7Nax9tiXIwDR+ NDQdVqyemmmQDFA2T9y+WFPpGAmxVCxXPcE14OVPC6VMSX2ufF4r2jNbSVfBIt0GRZ JSt0PQmNWOWeOZyBQQFaZEnR1baS5Dl5D8Pq3MnqHdhZS2Lz2DtLUxDBAiM8TCyO23 gYP3uhN51u/Kg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 16/33] soundwire: cadence: Don't overwrite msg->buf during write commands Date: Wed, 12 Oct 2022 20:23:15 -0400 Message-Id: <20221013002334.1894749-16-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221013002334.1894749-1-sashal@kernel.org> References: <20221013002334.1894749-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Cc: Sasha Levin , alsa-devel@alsa-project.org, Richard Fitzgerald , Pierre-Louis Bossart , Vinod Koul , yung-chuan.liao@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Richard Fitzgerald [ Upstream commit ba05b39d265bdd16913f7684600d9d41e2796745 ] The buf passed in struct sdw_msg must only be written for a READ, in that case the RDATA part of the response is the data value of the register. For a write command there is no RDATA, and buf should be assumed to be const and unmodifable. The original caller should not expect its data buffer to be corrupted by an sdw_nwrite(). Signed-off-by: Richard Fitzgerald Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20220916103505.1562210-1-rf@opensource.cirrus.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/soundwire/cadence_master.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index c6d421a4b91b..a3247692ddc0 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -501,9 +501,12 @@ cdns_fill_msg_resp(struct sdw_cdns *cdns, return SDW_CMD_IGNORED; } - /* fill response */ - for (i = 0; i < count; i++) - msg->buf[i + offset] = FIELD_GET(CDNS_MCP_RESP_RDATA, cdns->response_buf[i]); + if (msg->flags == SDW_MSG_FLAG_READ) { + /* fill response */ + for (i = 0; i < count; i++) + msg->buf[i + offset] = FIELD_GET(CDNS_MCP_RESP_RDATA, + cdns->response_buf[i]); + } return SDW_CMD_OK; } -- 2.35.1