[PATCH 4.5 27/87] nfc: st21nfca: Fix static checker warning

From: Greg Kroah-Hartman
Date: Mon May 30 2016 - 17:53:45 EST


4.5-stable review patch. If anyone has any objections, please let me know.

------------------

From: Christophe Ricard <christophe.ricard@xxxxxxxxx>

commit b58afe6d6d3a53af165d5946f12c4b08c95acd58 upstream.

Fix static checker warning:
drivers/nfc/st21nfca/i2c.c:530 st21nfca_hci_i2c_acpi_request_resources()
error: 'gpiod_ena' dereferencing possible ERR_PTR()

Fix so that if no enable gpio can be retrieved an -ENODEV is returned.

Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Fixes: dfa8070d7f64 ("nfc: st21nfca: Add support for acpi probing for i2c device.")
Signed-off-by: Christophe Ricard <christophe-h.ricard@xxxxxx>
Signed-off-by: Samuel Ortiz <sameo@xxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
drivers/nfc/st21nfca/i2c.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -524,8 +524,10 @@ static int st21nfca_hci_i2c_acpi_request
/* Get EN GPIO from ACPI */
gpiod_ena = devm_gpiod_get_index(dev, ST21NFCA_GPIO_NAME_EN, 1,
GPIOD_OUT_LOW);
- if (!IS_ERR(gpiod_ena))
- phy->gpio_ena = desc_to_gpio(gpiod_ena);
+ if (!IS_ERR(gpiod_ena)) {
+ nfc_err(dev, "Unable to get ENABLE GPIO\n");
+ return -ENODEV;
+ }

phy->gpio_ena = desc_to_gpio(gpiod_ena);