hwmon: qpnp-adc-current: Fix error path
Invalid jump to cleanup before the hwmon device
is registered. Cleanup the error path to avoid
panic if a failure occurs before hwmon device
register occurs.
Change-Id: I3477d207dc6402bed33d15723f2763ee85a1ca46
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
diff --git a/drivers/hwmon/qpnp-adc-current.c b/drivers/hwmon/qpnp-adc-current.c
index 2d70faa..adaff41 100644
--- a/drivers/hwmon/qpnp-adc-current.c
+++ b/drivers/hwmon/qpnp-adc-current.c
@@ -1249,8 +1249,7 @@
GFP_KERNEL);
if (!adc_qpnp) {
dev_err(&spmi->dev, "Unable to allocate memory\n");
- rc = -ENOMEM;
- goto fail;
+ return -ENOMEM;
}
iadc->dev = &(spmi->dev);
@@ -1259,7 +1258,7 @@
rc = qpnp_adc_get_devicetree_data(spmi, iadc->adc);
if (rc) {
dev_err(&spmi->dev, "failed to read device tree\n");
- goto fail;
+ return rc;
}
iadc->vadc_dev = qpnp_get_vadc(&spmi->dev, "iadc");
@@ -1267,7 +1266,7 @@
rc = PTR_ERR(iadc->vadc_dev);
if (rc != -EPROBE_DEFER)
pr_err("vadc property missing, rc=%d\n", rc);
- goto fail;
+ return rc;
}
mutex_init(&iadc->adc->adc_lock);