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 X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E89CBC4361A for ; Fri, 4 Dec 2020 08:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AF0422582 for ; Fri, 4 Dec 2020 08:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728814AbgLDIhM (ORCPT ); Fri, 4 Dec 2020 03:37:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:37350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727402AbgLDIhL (ORCPT ); Fri, 4 Dec 2020 03:37:11 -0500 From: Arnd Bergmann Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: Cheng-Yi Chiang , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Benson Leung , Enric Balletbo i Serra , Tzung-Bi Shih Cc: Arnd Bergmann , Guenter Roeck , Herbert Xu , Ard Biesheuvel , Eric Biggers , Yu-Hsuan Hsu , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] ASoC: cros_ec_codec: fix uninitialized memory read Date: Fri, 4 Dec 2020 09:36:11 +0100 Message-Id: <20201204083624.2711356-1-arnd@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann gcc points out a memory area that is copied to a device but not initialized: sound/soc/codecs/cros_ec_codec.c: In function 'i2s_rx_event': arch/x86/include/asm/string_32.h:83:20: error: '*((void *)&p+4)' may be used uninitialized in this function [-Werror=maybe-uninitialized] 83 | *((int *)to + 1) = *((int *)from + 1); Change the length of the command to only pass down the part of the structure that has been initialized, as Tzung-Bi Shih explains that only that member is meant to be used. Cc: Tzung-Bi Shih Fixes: 727f1c71c780 ("ASoC: cros_ec_codec: refactor I2S RX") Signed-off-by: Arnd Bergmann --- sound/soc/codecs/cros_ec_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c index 58894bf47514..6ec673573c70 100644 --- a/sound/soc/codecs/cros_ec_codec.c +++ b/sound/soc/codecs/cros_ec_codec.c @@ -348,7 +348,7 @@ static int i2s_rx_event(struct snd_soc_dapm_widget *w, } return send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_I2S_RX, - (uint8_t *)&p, sizeof(p), NULL, 0); + &p.cmd, sizeof(p.cmd), NULL, 0); } static struct snd_soc_dapm_widget i2s_rx_dapm_widgets[] = { -- 2.27.0