From patchwork Mon Oct 24 11:32:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9436 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp479238wru; Mon, 24 Oct 2022 07:18:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM54zx/acDcQYPX8G53XYbybxVNha7JGIyTWtu2uvsOmkcDhUD8O9A2pLhqIGaQD7/5hxYgL X-Received: by 2002:a05:6402:298d:b0:451:5fc5:d423 with SMTP id eq13-20020a056402298d00b004515fc5d423mr30496241edb.102.1666621125578; Mon, 24 Oct 2022 07:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621125; cv=none; d=google.com; s=arc-20160816; b=AAjNNWja4zUtL+NdNVRkge2uCH9vhbcsp2sv/yFrmskRcgIf1TcH2frzubzmYXT323 IWd9YNllFgx+AFRxF/az8re/tVxq9YadRB50OL6UjZEtsKI/eK4tLINgW6bLImibxAB/ 7capW1LoP0wC+yQsnYDKFL7jCm+0vxLBxv4HJ/Z15kTHJSbjNftqhSiK5IMBgV/Wgitk j1u2GpQQ5XCnfYnqNWSP/txjgripocirbIFeTnswl5auFTNWMSmcZK8GRK8i3il+t0NG 93RDXQwXxmxA7a3yQXnA5bwu5ujX8UeKhLAHqbz3QSEUL8R+4/zGII79dPA3wl2kZ/gR lDuQ== 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=55i4xDSgE2IbVtFLZLygVL64rS+NZAVGVtJgnedq9ao=; b=v0rnZGKyNA8AaYh1OpUyVpcbQJN3g/Js3kbT4gU8oOWLFflX3GtARokuWQRacIAhup kgbMoMOMRVReNnWi+V76a4hWuFizBigMYuO7wB608Dzgod26CwlNH9SjqjGvDsS/MUvl vx3CpeVV4jXOnBFrjRmB9oMKcOZqbQkEQzTxq9YJAQdU7ngD/dGsRv48ZRn+dNrrKEGN Rd1BEylo3VvvklTu1e6QhlOzXyAiNCqNQF8GlRcJwVOWO42UyxCy3mV4UVS0HKGcMTAX gLVzrL5LvOzWKDkz+w/2fRxVJyb6B+HEcoCsFcW3rlDP1ajkv33LsSmFFtOIg8wkXAq9 jXAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z+spuVQC; 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 ez14-20020a056402450e00b00461d9b36740si1838358edb.240.2022.10.24.07.18.12; Mon, 24 Oct 2022 07:18:45 -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=z+spuVQC; 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 S233450AbiJXONS (ORCPT + 99 others); Mon, 24 Oct 2022 10:13:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237168AbiJXOKT (ORCPT ); Mon, 24 Oct 2022 10:10:19 -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 E4AF3C8234; Mon, 24 Oct 2022 05:52:17 -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 5D34EB8125C; Mon, 24 Oct 2022 12:31:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B305EC433D6; Mon, 24 Oct 2022 12:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614707; bh=Af8giS2+ZfpdZxS5MHM8Plt2o38OtS7fPeNrZbHoCb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z+spuVQCWbSyFqKhLvWyHTvaQHzSG+Vp+lGcdRfYujMIuig+IfEWCDlcvlN6qF5LK MiPilTmgtZycf7R/4DhIcQPcNNhWgEIfxli0i5JlgU8K/tHxVeZHsWyvB0VsLsHmjE s0/SC48i+itijmqAD+I/3CQwfAZgXbBZiSGUwUU8= 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.10 364/390] soundwire: cadence: Dont overwrite msg->buf during write commands Date: Mon, 24 Oct 2022 13:32:41 +0200 Message-Id: <20221024113038.497535574@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747578913085839774?= X-GMAIL-MSGID: =?utf-8?q?1747578913085839774?= 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; }