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: <20160921075528.14452-1-nicolas.ferre@atmel.com>
Date:   Wed, 21 Sep 2016 09:55:28 +0200
From:   Nicolas Ferre <nicolas.ferre@...el.com>
To:     <linux@...tdown.ru>, Mark Brown <broonie@...nel.org>,
        Alexandre Belloni <alexandre.belloni@...e-electrons.com>,
        Boris BREZILLON <boris.brezillon@...e-electrons.com>,
        <linux-spi@...r.kernel.org>
CC:     Ludovic Desroches <ludovic.desroches@...el.com>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>,
        Cyrille Pitchen <cyrille.pitchen@...el.com>,
        Wenyou Yang <wenyou.yang@...el.com>,
        Nicolas Ferre <nicolas.ferre@...el.com>
Subject: [PATCH] spi: atmel: use managed resource for gpio chip select

Use the managed gpio CS pin request so that we avoid having trouble
in the cleanup code.
In fact, if module was configured with DT, cleanup code released
invalid pin.  Since resource wasn't freed, module cannot be reinserted.

Reported-by: Alexander Morozov <linux@...tdown.ru>
Signed-off-by: Nicolas Ferre <nicolas.ferre@...el.com>
---
 drivers/spi/spi-atmel.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 8feac599e9ab..4e3f2345844a 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1248,7 +1248,8 @@ static int atmel_spi_setup(struct spi_device *spi)
 			return -ENOMEM;
 
 		if (as->use_cs_gpios) {
-			ret = gpio_request(npcs_pin, dev_name(&spi->dev));
+			ret = devm_gpio_request(&spi->dev,
+						npcs_pin, dev_name(&spi->dev));
 			if (ret) {
 				kfree(asd);
 				return ret;
@@ -1471,13 +1472,11 @@ static int atmel_spi_transfer_one_message(struct spi_master *master,
 static void atmel_spi_cleanup(struct spi_device *spi)
 {
 	struct atmel_spi_device	*asd = spi->controller_state;
-	unsigned		gpio = (unsigned long) spi->controller_data;
 
 	if (!asd)
 		return;
 
 	spi->controller_state = NULL;
-	gpio_free(gpio);
 	kfree(asd);
 }
 
-- 
2.9.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ