From patchwork Sat Oct 22 07:29:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1109447wrr; Sat, 22 Oct 2022 01:48:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ZlKHpWukcd/Vhvb+WuCAy3GHE+IF1zkRU3YVvMf187t8acHwQyJf15UyA73iCmX0u8Ou2 X-Received: by 2002:a17:907:845:b0:731:2f6c:6dbd with SMTP id ww5-20020a170907084500b007312f6c6dbdmr18986371ejb.551.1666428516223; Sat, 22 Oct 2022 01:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428516; cv=none; d=google.com; s=arc-20160816; b=kdT6yNNuvbho2Fillvs0vvNn03bL2kmbEwln+ln4XB/FPX9+kKFQ5VZH8oKN3y+AP5 hgw3X8TRdsWixp5FfKSBiVCHUy8brf4i3Q028emyNbeLYlkcY7pAD2Q4SiXUa5OUOICC JpWeVOmk7H7yfm+QMi8pcU7FDV8YqJw/H7gSZBux2/I6cu7W9e1OZoENVAc5669tHu1u UavsZVYDtauVbtZ0nmiUhXEnQvqEdXChDN9FjtNuEu6FldAaN6Bm3816rkE9+7LNmGZZ lT9j/fFY6VAtzxzmbzgjAwbpZpqzF9C0Kksj9dXVE429T22BMD4Yn2lnjKe0WogfuO1Y B5HA== 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=SdgYdefcGCbU65olKFZB7iZPHeAGecHJXR2fG4geXHM=; b=vHIZzybsgNGHDXkPulgX+ckI7RE8XC0HpSuyPqUPG7jAsKq+ZzU0NaqfmRF93/FQNZ 4Nzdct0jwTljf5rdjpzywXH9Mxp5VbRKXMJfYx2v9jjTVCJZPHqHcFtm6M5MX9Zq0Q34 HcQTgvyATtsGQF+LuBAZ8YHG732GtTYInLieUMCMdxKILxJuMVgocluAIl+RUHCfTxoE QyUc0Rgebr5hlHFeYqwbDO2ycABmOaPb3HI6TuKE1i02MVN6DtRTSZg+lSBQa9vHu/ly VJ3itYfav3V1LMrDS4OK5UcP99eyMWRjQVj4cnTM1tHjTCG4RXWj1htQd0QAgOCo4mRy +C7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0LvcuYE9; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t30-20020a056402241e00b0046069e4590bsi6831852eda.104.2022.10.22.01.48.12; Sat, 22 Oct 2022 01:48:36 -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=0LvcuYE9; 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 S234138AbiJVIrn (ORCPT + 99 others); Sat, 22 Oct 2022 04:47:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234859AbiJVInt (ORCPT ); Sat, 22 Oct 2022 04:43:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDAA42EA28A; Sat, 22 Oct 2022 01:07:24 -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 67F0BB82E42; Sat, 22 Oct 2022 08:05:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D98AFC433C1; Sat, 22 Oct 2022 08:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425946; bh=VZBw5DsUX6oh/4FnMOXMdw0076F1lklCffGNz1UYs/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0LvcuYE9o+/SC8IFH0eWsm4sq+3oy1vspom2ZeYrRuFPw/CQhGglClGHI+2pZRBM7 ZwJaPWmG7CU4BzK38zxHKbAQOIazrHV+zn3iUPRBzNQVPokXvnF7fGwSykvCgKm7WL 6Y7Er7yzYIIU533ytROSZwgJw8Wlv9wAVFE8C/lc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Fitzgerald , Pierre-Louis Bossart , Vinod Koul , Sasha Levin Subject: [PATCH 5.19 668/717] soundwire: cadence: Dont overwrite msg->buf during write commands Date: Sat, 22 Oct 2022 09:29:07 +0200 Message-Id: <20221022072527.960194151@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747376947946818957?= X-GMAIL-MSGID: =?utf-8?q?1747376947946818957?= 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; }