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>
This commit is contained in:
parent
7959a7c477
commit
f88af7e7d3
|
@ -1255,12 +1255,15 @@ static int __devinit max1363_probe(struct i2c_client *client,
|
||||||
struct regulator *reg;
|
struct regulator *reg;
|
||||||
|
|
||||||
reg = regulator_get(&client->dev, "vcc");
|
reg = regulator_get(&client->dev, "vcc");
|
||||||
if (!IS_ERR(reg)) {
|
if (IS_ERR(reg)) {
|
||||||
ret = regulator_enable(reg);
|
ret = PTR_ERR(reg);
|
||||||
if (ret)
|
goto error_out;
|
||||||
goto error_put_reg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = regulator_enable(reg);
|
||||||
|
if (ret)
|
||||||
|
goto error_put_reg;
|
||||||
|
|
||||||
indio_dev = iio_allocate_device(sizeof(struct max1363_state));
|
indio_dev = iio_allocate_device(sizeof(struct max1363_state));
|
||||||
if (indio_dev == NULL) {
|
if (indio_dev == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
@ -1323,6 +1326,7 @@ static int __devinit max1363_probe(struct i2c_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_uninit_ring:
|
error_uninit_ring:
|
||||||
iio_ring_buffer_unregister(indio_dev->ring);
|
iio_ring_buffer_unregister(indio_dev->ring);
|
||||||
error_cleanup_ring:
|
error_cleanup_ring:
|
||||||
|
@ -1335,12 +1339,10 @@ error_free_device:
|
||||||
else
|
else
|
||||||
iio_device_unregister(indio_dev);
|
iio_device_unregister(indio_dev);
|
||||||
error_disable_reg:
|
error_disable_reg:
|
||||||
if (!IS_ERR(st->reg))
|
regulator_disable(reg);
|
||||||
regulator_disable(st->reg);
|
|
||||||
error_put_reg:
|
error_put_reg:
|
||||||
if (!IS_ERR(st->reg))
|
regulator_put(reg);
|
||||||
regulator_put(st->reg);
|
error_out:
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue