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: 167324 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2018922ilk; Thu, 20 Jun 2019 05:37:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZapXypHBgivb+cmwCNqGRnSl6aH3idCWUIQ02lqcSW8DZyJYbdVqFnDitG/TgbCdxI+T+ X-Received: by 2002:a63:c14c:: with SMTP id p12mr12730819pgi.138.1561034229058; Thu, 20 Jun 2019 05:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561034229; cv=none; d=google.com; s=arc-20160816; b=Yd7KiyVcmxBgtTftlBj4ilQo0RMK463v7Oe0y8ViM0DON4f4GAz9akZMzw9rbm/E/x wMnQ7BN5N6R8xjB/KY/LaRAdjee7SUyT20ylwCMADMm2H5UlEpjhq9xfrqWzeodbCiRZ l7R1UJcbkwbI/81+fYV9W/jbTm8MCW+slhXfCFRaKVsBXzfcJ+nwxAjYzfLD8q4e6wvK aSucqnUun2qmu6GpT/PLmQItwJ4NssucjLkG/9idG62ML1OuGogzpsZqzSyocVBV2MCk va6MCBuutTjTCr6i2DEjnmcLSY3FYd/ITRbHnUFhf2bPxN6+/TE0Bbo2gnlt8eY0fkKU G8dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=LPD6WWTjH8Ax5as56kI7pGVOzNQxzbf8W5J7T7qdeTE=; b=IRHaHNC614bq91DvVw1TNmF4q7aTGEtGZ0HCILzpvoU70HRVexKnPqtvu1jicNavfd eTcqGLMK5DFNrOPFmooaGtrVUuYNflcLYB/dDD9NOEvzVEtZfdRbGeQEsGmnKAdR0a56 H68+y6hPcRx53kq97G1Le7YcPWv52eIHQH2wCMyvEaEcVoZ/iY1L0w7PCD9Tp9EwK6V3 5gCqyoCdPOm91AYD6WrXg3Fdls+lB6CzXCqGxR2JkVGA+3eBuCS8zVchcFXjaPW8/upz 89X1KeKDe/o7msUYeWlr9Jz6dEMRuSm4dHqwztl4RnOGq0vmYBNugYcgf2BRjQDODZqC XuIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IrOWw/tx"; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si17592057pll.417.2019.06.20.05.37.08; Thu, 20 Jun 2019 05:37:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IrOWw/tx"; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726238AbfFTMhI (ORCPT + 1 other); Thu, 20 Jun 2019 08:37:08 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55638 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726592AbfFTMhI (ORCPT ); Thu, 20 Jun 2019 08:37:08 -0400 Received: by mail-wm1-f67.google.com with SMTP id a15so2903858wmj.5 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=DBGeGAl27VEDDpxiKQB0dzLqj9u0Opf/O7P77CmVN0tDfcWFWYzU89qaTu/F5/vXyr jqUnuf27Qyaay/u5Plms8t3q72XEaFfbg/J9SWJboxvskR+PwbbT94ags2KNtjI7abRh td7DuLDQe9uDoJU49mRDbAlIObcLTIyaYO0gyxY6FkSe/GOutNMtVBGO2JeAr4CcLqUt J5ZeLOwRI4nc+Op9vtnaT2DlLAKmI6n9C3jxvK1J6CxWFPC6EJ/C/A6y/yvwQ+ek/r4X Vi8ppfYla6iXjVwwC1R1tQeqXfAeX2/Du5hwfamrodUdbr9rp+53p5HpBePu6JzOJqE6 EMcA== X-Gm-Message-State: APjAAAVjewjwEsGSv8RGc34E+u7eKxCTZco2hVn1GMhQlP8W19J1XFb5 +sj2+D2gEfdBOMvyEKGe0nYlpoMUzkM= 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-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org 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 --- drivers/spi/spi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.20.1 Tested-by: Jarkko Nikula Acked-by: Mika Westerberg 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);