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: 11003811 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 E705614B6 for ; Wed, 19 Jun 2019 09:53:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D540B289F5 for ; Wed, 19 Jun 2019 09:53:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8EB628A50; Wed, 19 Jun 2019 09:53:32 +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 5FA7A289F5 for ; Wed, 19 Jun 2019 09:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727002AbfFSJxb (ORCPT ); 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-Google-Smtp-Source: APXvYqyhWECSNpWnjcYlUH2TFCJqqtFVdgjFX4hBJ5vwQ/M0l9PG7qsLV5R8TwGb4i9xzOkKoVWLsg== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Mika Westerberg --- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;