From patchwork Wed Jun 19 09:52:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167219 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp508364ilk; Wed, 19 Jun 2019 02:53:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5g8qUwor/8AG+flVOHuIX2mz4aMEuicg15jYZRzwj6E3WFoCQqQcoZT3IsmDczbv9Sc6d X-Received: by 2002:a17:90a:80c4:: with SMTP id k4mr10431063pjw.74.1560938012372; Wed, 19 Jun 2019 02:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560938012; cv=none; d=google.com; s=arc-20160816; b=DUZjjxbSf7/zUtQ3WnoSGwv9eNeg+vk69JyET7pCwQWop+CLUK9JTZqCymugmXubvM z+TDLLFiyp7eMMz4mEQXwiimzn5LeTUhlKyy3IVLvBWSXgVA7lxuCR4UGl08Vt08kW3j VDhgzdTbUrF4ZvWFVbhy3B0DjeIRPSZngNaU1b96qIVflMd2zKbBK4AC3YXVRLA8fZbD ns9Ny7yNTUZ1vGzvb9KQpcwWrrWZ2yE5eynF83vJw3mbtWJybOkzjtb8avLaDFtXGjHl 92eOkqKqx8ZfijhKuAP7KD1hxGDCbeSVTC9/FIjT+lUz5/JdrcTSZiH78Ry5rifS/qgz QFeA== 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=chQPrFFBsSaN5Zy70hzC849/NN1iqycFvOtokhwycjY=; b=Mz/jtOAGKb5tqDY1jQYRihPU+YalDPBLfw/traTl3ZO3yI1XHoxfriKtKXDNjQSQwQ ZmZ5VcOWzWOYJOxEP5aFwsialbn7l8HPMMsfSDpig4jXGUmkap2KAQEDm7yxKxvxqsCk wNpNfYSxoSc0EV5D3/rMOgfrJYrcCCCU7pVAJsDd98bQ1pd6s5wRnjxK48jvQanArHhX klu6xuZkqzXL6jkdbU3nhmyKea712EHlkb6iSwzzue95R7hKEaO3YRVTuWOwMp4fQokf IVjt8or75seNMiqyj6JqjHQ7rmX5h/cAN1tpro6z3gGl9slX7kRj09CpVwCCd5NwcOvB ny/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Rtr/JMKA"; 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 o11si990039pjb.30.2019.06.19.02.53.32; Wed, 19 Jun 2019 02:53:32 -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="Rtr/JMKA"; 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 S1727002AbfFSJxb (ORCPT + 1 other); Wed, 19 Jun 2019 05:53:31 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33882 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbfFSJxb (ORCPT ); Wed, 19 Jun 2019 05:53:31 -0400 Received: by mail-wr1-f67.google.com with SMTP id k11so2691294wrl.1 for ; Wed, 19 Jun 2019 02:53:30 -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=chQPrFFBsSaN5Zy70hzC849/NN1iqycFvOtokhwycjY=; b=Rtr/JMKAL2PriusG0MZ4goS/8DrMhKNZlbzm6V3Jm48Yml7XPqhP1zeAjd0usen83e 7KW2FCkWHyxrbKO/nyBoeAe2bq+6yvdZmqdTpGMN+YiKq6TfqFNpH3nWGD19T9CBhfcs cVuGLemtwOUA86X4PZhVa8O35exsv93OXCyOlr7Nkr39PtB43r/icxxD5i3HW0ILnCMg QgRNaS4sUVAT9P9MiytmoTtOK4dM7oFyk8ujbQ42NweMUOmyiNbIkIKjkkNlw1uY3vCn kANpyDMSb8xAE7d+u8E/YCKbkWdcMf91oNYeVfdvZQbuDAi9Z+xHQ0wezCgkXgtBNCmJ EDLw== 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=chQPrFFBsSaN5Zy70hzC849/NN1iqycFvOtokhwycjY=; b=W2NTZcgU2uzjLSG0jjYi388JSF84kcSo+c3sCmX7C8sEwarYN3qWD86Kqcp2sNOuta 2KUi1/1jthxmTTbQC3lieptfPKYXVrz9pAgTqdLZ6yjlkE+DLapzuMnbOzCTk+ccjlZc nZhCPY86pFFUlP5est8QPra2RfKFY81Y/KUnN6FhPKlV8lvgx71GVAAnPyUPviCASRAs QK6pU/LfgZPlzETXxPGVq9t7G5NVXrviZy8w39L46k7RMLeJ+HtRKSMxGJ8gGan20ZDG 0XTP0gtYyIqYln9y83eSYiNu0v3PIBvuJvKwDxC4DZl0ruReUBnEd8is+JZI3O1rOwRG mmbA== X-Gm-Message-State: APjAAAX/yJ687WnproGuuKjtmqahUF2knVXP24+j+5BdyJLa5GfzC7m5 G9PIfvKjMiXUIGNoXulVNUh9D9HyFLl79Q== X-Received: by 2002:a5d:6949:: with SMTP id r9mr68679902wrw.73.1560938009014; Wed, 19 Jun 2019 02:53:29 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:21a3:60fe:6e8e:8104]) by smtp.gmail.com with ESMTPSA id l4sm674706wmh.18.2019.06.19.02.53.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 02:53:28 -0700 (PDT) From: Ard Biesheuvel To: linux-spi@vger.kernel.org Cc: broonie@kernel.org, Ard Biesheuvel , kbuild test robot , Dan Carpenter , 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: fix incorrect ACPI parent check Date: Wed, 19 Jun 2019 11:52:54 +0200 Message-Id: <20190619095254.19559-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 The ACPI device object parsing code for SPI slaves enumerates the entire ACPI namespace to look for devices that refer to the master in question via the 'resource_source' field in the 'SPISerialBus' resource. If that field does not refer to a valid ACPI device or if it refers to the wrong SPI master, we should disregard the device. Current, the valid device check is wrong, since it gets the polarity of 'status' wrong. This could cause issues if the 'resource_source' field is bogus but parent_handle happens to refer to the correct master (which is not entirely imaginary since this code runs in a loop) So test for ACPI_FAILURE() instead, to make the code more self explanatory. Fixes: 4c3c59544f33 ("spi/acpi: enumerate all SPI slaves in the namespace") Reported-by: kbuild test robot Reported-by: Dan Carpenter 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Acked-by: Mika Westerberg diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index c8adcc97f3ef..50d230b33c42 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1859,7 +1859,7 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data) sb->resource_source.string_ptr, &parent_handle); - if (!status || + if (ACPI_FAILURE(status) || ACPI_HANDLE(ctlr->dev.parent) != parent_handle) return -ENODEV;