Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1072084rwi; Wed, 19 Oct 2022 06:27:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7C/GfmrTMNxkcdpDhel2dVRR9ZYKbGThlLf/9oxt2IgJ3WA0PicE3jRN5TQIsRbnA+WNzp X-Received: by 2002:a05:6a00:14d4:b0:563:9296:f320 with SMTP id w20-20020a056a0014d400b005639296f320mr8477493pfu.27.1666186064767; Wed, 19 Oct 2022 06:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666186064; cv=none; d=google.com; s=arc-20160816; b=JWmuzC3ebbUUl7U3IEMchj5lvK8+d1jLYP3skTkplexx+14sDG7tkssDF2iUe/KSd4 EcB4XYhFd8x7F32TMtUvPFbj7tY9FRDdp4RxhQcpflkHmHJAd5CdK/11r6jNdT+WQvRt PcAdf3tekeJl5XmUjig/JIHmc1/PXFDqvXnWuPf4/0x6tKJFED8aw5a/lAGMCrOuTjcn cGfzEnYIlYMSZkEQCEWi5Hey/4UH0NogROHsh/X0+4xF/AarG4QRS/tqcRYCPKQpIs0Y 5cVNfUNoLrD0VJK+oZsneoqP8zAizuwCeARN/QC+NILhB7BKOhw6GsQL3UprpMbKdvl6 qwCA== 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=PTwdJFiQdzIlVktNA+/m+PCHVdEQP1KRAklJgBxnjft0IGQYp6gsnY298yScPzmARE YjyqMPYk9cB3Gd/TMdG70M9vpmBHuj5dWC12nPx/Li6orCWmYB2fxpfix/7t1OMIaPzJ 5FiuYlx7e03jrsu2gtBc9PPrwohBAYc90jS+5bv2IC4cvB3Vq9CVmIFujHGJk+HL9Oat 3BAcmq5oxKa/51PgYl95q+HSnKs4oVnP7WPYmTStKYUMABsfCmTXQSoZMHBm1vA3iqof rs50qWWQ2xmIQ6F6OGv7Tq8qKz6pBUoFqqPWv8t3s0rsbwidv3oEHZxe22s5+OoiY28u dhEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Nt2wB8Co; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a056a00134900b00565eb80af7fsi18672634pfu.343.2022.10.19.06.27.17; Wed, 19 Oct 2022 06:27:44 -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=Nt2wB8Co; 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 S231978AbiJSMdC (ORCPT + 99 others); Wed, 19 Oct 2022 08:33:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231489AbiJSMcm (ORCPT ); Wed, 19 Oct 2022 08:32:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D3181D0D74; Wed, 19 Oct 2022 05:11:11 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 049E8617E1; Wed, 19 Oct 2022 09:14:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C5F1C433C1; Wed, 19 Oct 2022 09:14:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170853; bh=VZBw5DsUX6oh/4FnMOXMdw0076F1lklCffGNz1UYs/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nt2wB8CoOeHpSrqC4ecYExZSI4ljq9k/oT3ron7CVqTRPgOkaq3+rBy4dSasHt/oK 8cJ/f0j1x/LLoKu8DMYSLdf2DOpcoAVkbFSPRmo9FcLM6K2/gDIpWkvT1pMgQbTr3q CZeQUpwMtVTkYDAAK1Sxl7e35ttNpAU9+ZLweAXU= 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 6.0 810/862] soundwire: cadence: Dont overwrite msg->buf during write commands Date: Wed, 19 Oct 2022 10:34:57 +0200 Message-Id: <20221019083325.708476346@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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