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 B734EC4332F for ; Thu, 13 Oct 2022 00:18:07 +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 F03632864; Thu, 13 Oct 2022 02:17:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F03632864 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1665620285; bh=VZBw5DsUX6oh/4FnMOXMdw0076F1lklCffGNz1UYs/M=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aJwf8F5+4X68b+XfcqUeLL+Dix10jHS64GLLBC5ruUETvVwDMKs1tZ4Ja6YiQX4B9 GNKLya1EMFjGIqLDRGmlN163fR6KvJRofOU6RO0KAJQf4ndLbVkLSjBiS0WVhoccJR FHDG7Q/81XpDXPg2ES4pIZjZymJ4DXs06Qnsz4/c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 93A25F8013D; Thu, 13 Oct 2022 02:17:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B0430F802DB; Thu, 13 Oct 2022 02:17:12 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B5CEEF800F4 for ; Thu, 13 Oct 2022 02:17:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B5CEEF800F4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dNYusnXb" 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 AF2AF616B6; Thu, 13 Oct 2022 00:17:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4706C433C1; Thu, 13 Oct 2022 00:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665620223; bh=VZBw5DsUX6oh/4FnMOXMdw0076F1lklCffGNz1UYs/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dNYusnXbNOXh0/6708zFP944aUVHe4dP67fmF6pJB7lM6iy3XphY9ytaqmGolIH8T b/BHCFqqMEAsr+B3H9mCFhiZYXDOPY6VY37Sa4ewgthwhry9gzb7N0evW2acm3vI1c lQl4GQDZvX1vNcvx9IUIrCfgCcK52FZqsaFLySV4xjI7VaSuqfWPMKBZw1rjJAYakG tyCm7NZI838gdfJ6fWfMDfpXkPWMEC6gaYVlfVIX4x5SMxRC7n2zrwuBRWcuu9mnkz +1qiEysnonWo9SCk/ze9IwGqboS5iXvle71zuil6VOqC3wTMJ9ar+b/chGd0WYgcP+ gWgNUUzMaAAyg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 28/67] soundwire: cadence: Don't overwrite msg->buf during write commands Date: Wed, 12 Oct 2022 20:15:09 -0400 Message-Id: <20221013001554.1892206-28-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221013001554.1892206-1-sashal@kernel.org> References: <20221013001554.1892206-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 4fbb19557f5e..42c5fae80efb 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -544,9 +544,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