lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171017104519.878892-1-arnd@arndb.de>
Date:   Tue, 17 Oct 2017 12:44:50 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     Mark Brown <broonie@...nel.org>
Cc:     Lucas Stach <l.stach@...gutronix.de>,
        Naresh Kamboju <naresh.kamboju@...aro.org>,
        Arnd Bergmann <arnd@...db.de>,
        Geert Uytterhoeven <geert+renesas@...der.be>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        linux-spi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] spi: fix bogus SPI bus number

lkft found a boot time regression on the Hikey board that has no
aliases entry for spi buses. of_alias_get_highest_id() here
returns -ENODEV, which is then used as the initial number for the
IDR allocation, and that in turn triggers a WARN_ON:

WARNING: CPU: 3 PID: 53 at include/linux/idr.h:113 spi_register_controller+0x890/0x940

This reworks the algorithm to turn any negative number into zero
again, restoring the original behavior for the Hikey case.

Fixes: 9ce70d49fa80 ("spi: fix IDR collision on systems with both fixed and dynamic SPI bus numbers")
Reported-by: Naresh Kamboju <naresh.kamboju@...aro.org>
Link: https://lkft.validation.linaro.org/scheduler/job/48009#L3147
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
Not tested yet, please review carefully
---
 drivers/spi/spi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 0483410e7cb3..4b6985ec962c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2116,9 +2116,11 @@ int spi_register_controller(struct spi_controller *ctlr)
 	}
 	if (ctlr->bus_num < 0) {
 		mutex_lock(&board_lock);
+		id = of_alias_get_highest_id("spi");
+		if (id < 0)
+			id = -1;
 		id = idr_alloc(&spi_master_idr, ctlr,
-			       of_alias_get_highest_id("spi") + 1,
-			       0, GFP_KERNEL);
+			       id + 1, 0, GFP_KERNEL);
 		mutex_unlock(&board_lock);
 		if (WARN(id < 0, "couldn't get idr"))
 			return id;
-- 
2.9.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ