From 504549c350bb66d43bf3aa46d91a68068c0f4b96 Mon Sep 17 00:00:00 2001 From: Jihoon Bang Date: Fri, 30 Sep 2011 17:22:55 -0700 Subject: i2c: fix crash when there is no regulator Calling regulator_disable causes system to crash when there is no regualtor. It calls regulator_disable only when regulators exist. Bug 871860 Change-Id: I7b714ed2423721d47ebae708dd453600cbf42312 Reviewed-on: http://git-master/r/56078 Reviewed-by: Jihoon Bang Tested-by: Jihoon Bang Reviewed-by: Ryan Wong Tested-by: Ryan Wong --- drivers/i2c/muxes/pca954x.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c index 34b253592cd0..5a80d6725bc0 100644 --- a/drivers/i2c/muxes/pca954x.c +++ b/drivers/i2c/muxes/pca954x.c @@ -274,8 +274,7 @@ static int __devinit pca954x_probe(struct i2c_client *client, if (ret) { dev_err(&client->dev, "%s: failed to enable vcc_i2c\n", __func__); - regulator_disable(data->vcc_reg); - goto exit_regulator_put; + goto exit_vcc_regulator_disable; } } @@ -290,9 +289,7 @@ static int __devinit pca954x_probe(struct i2c_client *client, */ if (i2c_smbus_read_byte(client) < 0) { dev_warn(&client->dev, "probe failed\n"); - regulator_disable(data->vcc_reg); - regulator_disable(data->i2c_reg); - goto exit_regulator_put; + goto exit_regulator_disable; } /* Decrease ref count for pca954x vcc */ @@ -342,9 +339,15 @@ static int __devinit pca954x_probe(struct i2c_client *client, virt_reg_failed: for (num--; num >= 0; num--) i2c_del_mux_adapter(data->virt_adaps[num]); +exit_regulator_disable: + if (data->i2c_reg) + regulator_disable(data->i2c_reg); +exit_vcc_regulator_disable: + if (data->vcc_reg) + regulator_disable(data->vcc_reg); exit_regulator_put: - regulator_put(data->vcc_reg); regulator_put(data->i2c_reg); + regulator_put(data->vcc_reg); exit_free: kfree(data); err: -- cgit v1.2.3