summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/adc
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2011-06-08 09:42:21 +0300
committerGreg Kroah-Hartman <gregkh@suse.de>2011-06-28 14:48:13 -0700
commitf88af7e7d338e067eff0c2b9e317da97488ff74c (patch)
tree043bf04188a165a252bf1c924efe2a43846c0ada /drivers/staging/iio/adc
parent7959a7c477b5dd284bb424c9cfbf917ae1664272 (diff)
Staging: iio: dereferencing uninitialized variable
In the error handling, it dereferences "st" before it has been initialized. I also just tidied it up a bit to remove some extra conditions. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/adc')
-rw-r--r--drivers/staging/iio/adc/max1363_core.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
index 98cebd26310f..72b0917412ee 100644
--- a/drivers/staging/iio/adc/max1363_core.c
+++ b/drivers/staging/iio/adc/max1363_core.c
@@ -1255,12 +1255,15 @@ static int __devinit max1363_probe(struct i2c_client *client,
struct regulator *reg;
reg = regulator_get(&client->dev, "vcc");
- if (!IS_ERR(reg)) {
- ret = regulator_enable(reg);
- if (ret)
- goto error_put_reg;
+ if (IS_ERR(reg)) {
+ ret = PTR_ERR(reg);
+ goto error_out;
}
+ ret = regulator_enable(reg);
+ if (ret)
+ goto error_put_reg;
+
indio_dev = iio_allocate_device(sizeof(struct max1363_state));
if (indio_dev == NULL) {
ret = -ENOMEM;
@@ -1323,6 +1326,7 @@ static int __devinit max1363_probe(struct i2c_client *client,
}
return 0;
+
error_uninit_ring:
iio_ring_buffer_unregister(indio_dev->ring);
error_cleanup_ring:
@@ -1335,12 +1339,10 @@ error_free_device:
else
iio_device_unregister(indio_dev);
error_disable_reg:
- if (!IS_ERR(st->reg))
- regulator_disable(st->reg);
+ regulator_disable(reg);
error_put_reg:
- if (!IS_ERR(st->reg))
- regulator_put(st->reg);
-
+ regulator_put(reg);
+error_out:
return ret;
}