spmi and gpio: qpnp: add pointer check in qpnp drivers

This patch is to fix KW errors in drivers. It's
neccessary to check NULL pointer before dereferencing it.
There're 4 issues related to it in qpnp-int.c and
qpnp-pin.c. Fix them by checking before.

CRs-Fixed: 505322
Change-Id: I2f82d1b24c219ef7e6b0977091fc353dac579cbc
Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>
This commit is contained in:
Zhenhua Huang 2013-07-11 01:52:36 +08:00 committed by Stephen Boyd
parent 9fb0f4fd7a
commit be77a90655
2 changed files with 9 additions and 1 deletions

View File

@ -589,6 +589,9 @@ int qpnp_pin_config(int gpio, struct qpnp_pin_cfg *param)
}
mutex_unlock(&qpnp_pin_chips_lock);
if (!q_spec)
return -ENODEV;
rc = _qpnp_pin_config(q_chip, q_spec, param);
return rc;
@ -1225,6 +1228,8 @@ static int qpnp_pin_probe(struct spmi_device *spmi)
if (!res) {
dev_err(&spmi->dev, "%s: node %s is missing has no base address definition\n",
__func__, d_node->of_node->full_name);
rc = -EINVAL;
goto err_probe;
}
rc = of_property_read_u32(d_node->of_node,

View File

@ -576,11 +576,14 @@ int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl,
unsigned long hwirq, busno;
int irq;
if (!spec || !spmi_ctrl)
return -EINVAL;
pr_debug("spec slave = %u per = %u irq = %u\n",
spec->slave, spec->per, spec->irq);
busno = spmi_ctrl->nr;
if (!spec || !spmi_ctrl || busno >= QPNPINT_MAX_BUSSES)
if (busno >= QPNPINT_MAX_BUSSES)
return -EINVAL;
hwirq = qpnpint_encode_hwirq(spec);