From patchwork Thu Jun 20 12:36:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 11006583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB4DB13AF for ; Thu, 20 Jun 2019 12:37:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B6C2286D1 for ; Thu, 20 Jun 2019 12:37:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E022286E4; Thu, 20 Jun 2019 12:37:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0627C286D1 for ; Thu, 20 Jun 2019 12:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729569AbfFTMhI (ORCPT ); Thu, 20 Jun 2019 08:37:08 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54918 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726238AbfFTMhI (ORCPT ); Thu, 20 Jun 2019 08:37:08 -0400 Received: by mail-wm1-f65.google.com with SMTP id g135so2905653wme.4 for ; Thu, 20 Jun 2019 05:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LPD6WWTjH8Ax5as56kI7pGVOzNQxzbf8W5J7T7qdeTE=; b=IrOWw/txUNL/7P7EppxJz6xQNsJRwXbqls++G4DQzPLt3dTCu6TkT5S4EdYmzLpk2B wPP/g0W+JWR6CrOeADQBM7XW3LKBJi5XgcY06juZoJv2N9TDLGT0uWX8OL+vcXU8g7v0 2ep8XbvM1a02LnkgsmtM4dLlKbk+BUKw/DU6ak65tojHDPLbznv7uOByzWYY/xDlF2FB WBtsSA8G4goWWP7A1P8vIcv7YouPqhgNEGLH/vswXMXjzYvE/7gUtKKL7gZklhe1Z/4O 2d2jgHQBX5p70o6gCvS7148AXCJKTveFBIwNm8FU6/IfvtozFaERG7yrj+15tDjD+FGP BmAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LPD6WWTjH8Ax5as56kI7pGVOzNQxzbf8W5J7T7qdeTE=; b=AlFezBdmoS3AOv3om6iQnHJLlRBsHSTcdeJap7aq3DSx/qhX3H9dM6zLx9+nQmUUOW CT6eViWczUt/YgSHePP/yy6BVJ9/1Qls48QJDhUqX5B9T25n3xXRRBR/N/Rg4keaRZ81 3YtBQbwcWLO9h5Db4zJf6Q2SUUZbsx1xWIj8CgwT5ZWCYCO5kbJl/LbYS2V6ChyMIRoP ViSsACQe/+TPqRkRC+QauaOGuf8UYU2sXp0LBJQB/8+IgXldFW7zmuuOZnVByBtNZ8TK qaWuQpZRzQ5gOdZCtidGAG13ltSAhgohaNeVLw3sfI4zueIBfe4tSe5VxQ60ZXRapx77 CRAw== X-Gm-Message-State: APjAAAWVS4a3LhCLmulydLv6TqP7DDYZe06rWJfLnuCVnuXc99uXi4Km kGJOEG+pVR2S9butkGu+VG0xCw== X-Google-Smtp-Source: APXvYqz8OT58MV1J4Wz/9Q4OEKqqMOOd7xEqoNs/FAbmmGRR8u1YwfpI/+cFSd7ycw/zWBdN66Q+LA== X-Received: by 2002:a1c:5a56:: with SMTP id o83mr2705277wmb.103.1561034225942; Thu, 20 Jun 2019 05:37:05 -0700 (PDT) Received: from localhost.localdomain (aaubervilliers-681-1-10-211.w90-88.abo.wanadoo.fr. [90.88.131.211]) by smtp.gmail.com with ESMTPSA id v2sm16633457wrn.30.2019.06.20.05.37.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 05:37:05 -0700 (PDT) From: Ard Biesheuvel To: linux-spi@vger.kernel.org Cc: broonie@kernel.org, Ard Biesheuvel , Mika Westerberg , andy.shevchenko@gmail.com, masahisa.kojima@linaro.org, "Rafael J. Wysocki" , Jarkko Nikula , linux-acpi@vger.kernel.org, Lukas Wunner Subject: [PATCH] spi/acpi: avoid spurious matches during slave enumeration Date: Thu, 20 Jun 2019 14:36:49 +0200 Message-Id: <20190620123649.4492-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the new SPI ACPI slave enumeration code, we use the value of lookup.max_speed_khz as a flag to decide whether a match occurred. However, doing so only makes sense if we initialize its value to zero beforehand, or otherwise, random junk from the stack will cause spurious matches. So zero initialize the lookup struct fully, and only set the non-zero members explicitly. Fixes: 4c3c59544f33 ("spi/acpi: enumerate all SPI slaves in the namespace") Cc: Mika Westerberg Cc: andy.shevchenko@gmail.com Cc: masahisa.kojima@linaro.org Cc: "Rafael J. Wysocki" Cc: Jarkko Nikula Cc: linux-acpi@vger.kernel.org Cc: Lukas Wunner Signed-off-by: Ard Biesheuvel Tested-by: Jarkko Nikula Acked-by: Mika Westerberg --- drivers/spi/spi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index a31e1e291335..4057f256ef76 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1953,7 +1953,7 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, { acpi_handle parent_handle = NULL; struct list_head resource_list; - struct acpi_spi_lookup lookup; + struct acpi_spi_lookup lookup = {}; struct spi_device *spi; int ret; @@ -1962,8 +1962,6 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, return AE_OK; lookup.ctlr = ctlr; - lookup.mode = 0; - lookup.bits_per_word = 0; lookup.irq = -1; INIT_LIST_HEAD(&resource_list);