diff options
author | Peter Chen <peter.chen@nxp.com> | 2017-09-15 10:05:21 +0800 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | 469a968000d4246cfd6ec9c72b4fc5371dc2c34e (patch) | |
tree | f56e8b61f3e171e05cebcf4f54934302ce729974 /drivers/staging | |
parent | 0ab08d144b6c029a5acc8fdeb29880d575c6fb25 (diff) |
MLK-16285-1 staging: typec: tcpci: move request interrupt to the end of probe
The tcpci_irq may visit tcpci->port if unexpected interrupt occurs
(eg, board design issue causes GPIO status is incorrect) and cause
NULL pointer dereference issue.
Besides, delete clear TCPC_ALERT and TCPC_ALERT_MASK code which are
already done at tcpci_init.
Signed-off-by: Peter Chen <peter.chen@nxp.com>
Acked-by: Li Jun <jun.li@nxp.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/typec/tcpci.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c index e0cdd37c5f65..3f1c505cc1e9 100644 --- a/drivers/staging/typec/tcpci.c +++ b/drivers/staging/typec/tcpci.c @@ -765,23 +765,25 @@ static int tcpci_probe(struct i2c_client *client, if (err < 0) return err; - /* Clear and disable chip interrupts */ - tcpci_write16(tcpci, TCPC_ALERT, 0xffff); - tcpci_write16(tcpci, TCPC_ALERT_MASK, 0); + tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc); + if (IS_ERR(tcpci->port)) + return PTR_ERR(tcpci->port); + + err = tcpci_ss_mux_control_init(tcpci); + if (err) + goto err1; err = devm_request_threaded_irq(tcpci->dev, client->irq, NULL, tcpci_irq, IRQF_ONESHOT | IRQF_TRIGGER_LOW, dev_name(tcpci->dev), tcpci); if (err < 0) - return err; - - err = tcpci_ss_mux_control_init(tcpci); - if (err) - return err; + goto err1; - tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc); - return PTR_ERR_OR_ZERO(tcpci->port); + return 0; +err1: + tcpm_unregister_port(tcpci->port); + return err; } static int tcpci_remove(struct i2c_client *client) |