Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp134530rwi; Wed, 12 Oct 2022 17:21:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5X1D1rCyagoz3n/aTmZywgK4dA7keQDtt7be8KIKKMwu+321orAImhU5W1MPKvdTAOWLX5 X-Received: by 2002:a17:907:2cf1:b0:78d:cafc:caba with SMTP id hz17-20020a1709072cf100b0078dcafccabamr11585781ejc.154.1665620491229; Wed, 12 Oct 2022 17:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665620491; cv=none; d=google.com; s=arc-20160816; b=LVY/IxjxLhazin+an+xpCwI4SGEwYiLEaZO+5Mv3eOsXTYaOOGtDjgoTgwQdnPQKJa 69FVfmSdKYvpuV2cukhWKJ5ZSamFlLb72b7yUwYfwrMtAZrlVdIJljVv/RcV9KvvXUiw 8eyWGmtu5AX+MGtrV3L8wVrtRUHHtYdjB1lRldXuT/LLzd/CkS2A2EExXaIIGhDxnGay jGFPuFlwysucT95eT38so3eiX/2ljIAjmbMtNuXBaQozWfkubok343ZdzyhQy1rNmv1U YbrZ1UjBJidxRra7UagNuNDI9WavJh+lrkksT0JrXBDHNGe6KiOV+bvA0qrmd1nr3gF/ 3E4Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SdgYdefcGCbU65olKFZB7iZPHeAGecHJXR2fG4geXHM=; b=G6BLIMd6SdTpFp/PVnEtJViX5Cv8dHVq3byP+D0PziH6N/nE/LlVWfnOgP7au0Qmdk byim+symhXQiOGip8uGS6vAQrwP7kpbetPp9uch4L98AMOW0uSskZ4srPbU1Q1oZjHaf hHCC2Vv0ZRQdjUHwN5bdK38fZO0fj1sm4pi4Vblflfi5PY5rSteb0BNMc8a92kLJC+vU l69wKSAvGalfdSwt14LB1WvmKCfvERJ/+CY9XHdWFLF7ZXz9h8m9Tawj/8FndFPGvqei zRc6FufMKj4AZFHoDKSd6KHD/KSvKKXU+J5nKGkl4zKwF5AAGaidMfbHZcrPnP1iLD+i w8IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dNYusnXb; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn16-20020a17090794d000b007429f0c69ccsi13867417ejc.579.2022.10.12.17.21.05; Wed, 12 Oct 2022 17:21:31 -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=@kernel.org header.s=k20201202 header.b=dNYusnXb; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230018AbiJMATJ (ORCPT + 99 others); Wed, 12 Oct 2022 20:19:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbiJMASK (ORCPT ); Wed, 12 Oct 2022 20:18:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE4A6DCAE8; Wed, 12 Oct 2022 17:17:16 -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 B39BFB81CC0; Thu, 13 Oct 2022 00:17:04 +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 Cc: Richard Fitzgerald , Pierre-Louis Bossart , Vinod Koul , Sasha Levin , yung-chuan.liao@linux.intel.com, alsa-devel@alsa-project.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 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 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: 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