msm: mhl: sii8334: Fix null pointer dereference at power off

Check for null pointer before disabling the regulators.
During cable connect/disconnect and suspend/resume check for
previous power state of mhl to avoid enabling/disabling gpio's
and regulators twice.

Change-Id: I44dc51122da4630974147b829236cb39c1ad54b0
Signed-off-by: Raghavendra Ambadas <rambad@codeaurora.org>
This commit is contained in:
raghavendra ambadas
2014-09-18 15:44:47 +05:30
parent c7c8677342
commit e77b4c5396
+22 -15
View File
@@ -398,7 +398,7 @@ static int mhl_sii_config(struct mhl_tx_ctrl *mhl_ctrl, bool on)
client = mhl_ctrl->i2c_handle;
if (on) {
if (on && !mhl_ctrl->irq_req_done) {
rc = mhl_vreg_config(mhl_ctrl, 1);
if (rc) {
pr_err("%s: vreg init failed [%d]\n",
@@ -423,7 +423,7 @@ static int mhl_sii_config(struct mhl_tx_ctrl *mhl_ctrl, bool on)
} else {
mhl_ctrl->irq_req_done = true;
}
} else {
} else if (!on && mhl_ctrl->irq_req_done) {
free_irq(mhl_ctrl->i2c_handle->irq, mhl_ctrl);
mhl_gpio_config(mhl_ctrl, 0);
mhl_vreg_config(mhl_ctrl, 0);
@@ -1532,22 +1532,29 @@ static int mhl_sii_reg_config(struct i2c_client *client, bool enable)
pr_debug("%s\n", __func__);
if (!enable) {
regulator_disable(reg_8941_vdda);
regulator_put(reg_8941_vdda);
reg_8941_vdda = NULL;
if (reg_8941_vdda) {
regulator_disable(reg_8941_vdda);
regulator_put(reg_8941_vdda);
reg_8941_vdda = NULL;
}
regulator_disable(reg_8941_smps3a);
regulator_put(reg_8941_smps3a);
reg_8941_smps3a = NULL;
if (reg_8941_smps3a) {
regulator_disable(reg_8941_smps3a);
regulator_put(reg_8941_smps3a);
reg_8941_smps3a = NULL;
}
regulator_disable(reg_8941_l02);
regulator_put(reg_8941_l02);
reg_8941_l02 = NULL;
regulator_disable(reg_8941_l24);
regulator_put(reg_8941_l24);
reg_8941_l24 = NULL;
if (reg_8941_l02) {
regulator_disable(reg_8941_l02);
regulator_put(reg_8941_l02);
reg_8941_l02 = NULL;
}
if (reg_8941_l24) {
regulator_disable(reg_8941_l24);
regulator_put(reg_8941_l24);
reg_8941_l24 = NULL;
}
return 0;
}