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]
Date:	Fri, 14 Nov 2014 14:32:24 -0800
From:	Dmitry Torokhov <dtor@...omium.org>
To:	Lauro Ramos Venancio <lauro.venancio@...nbossa.org>
Cc:	Aloisio Almeida Jr <aloisio.almeida@...nbossa.org>,
	Samuel Ortiz <sameo@...ux.intel.com>,
	Christophe Ricard <christophe.ricard@...il.com>,
	linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] NFC: st21nfca: fix error handling of irq_of_parse_and_map

Return value of irq_of_parse_and_map() is unsigned int, with 0
indicating failure, so testing for negative result never works.

Also report error returned by devm_gpio_request_one instead of
clobbering it with -ENODEV.

Signed-off-by: Dmitry Torokhov <dtor@...omium.org>
---
 drivers/nfc/st21nfca/i2c.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
index 0ea756b..6d6d282 100644
--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -531,20 +531,19 @@ static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client)
 				  "clf_enable");
 	if (r) {
 		nfc_err(&client->dev, "Failed to request enable pin\n");
-		return -ENODEV;
+		return r;
 	}
 
 	phy->gpio_ena = gpio;
 
 	/* IRQ */
-	r = irq_of_parse_and_map(pp, 0);
-	if (r < 0) {
-		nfc_err(&client->dev, "Unable to get irq, error: %d\n", r);
-		return r;
+	client->irq = irq_of_parse_and_map(pp, 0);
+	if (!client->irq) {
+		nfc_err(&client->dev, "Unable to get irq\n");
+		return -EINVAL;
 	}
 
 	phy->irq_polarity = irq_get_trigger_type(r);
-	client->irq = r;
 
 	return 0;
 }
-- 
2.1.0.rc2.206.gedb03e5


-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ