diff options
author | Meng Wang <mwang@codeaurora.org> | 2016-05-13 13:57:10 +0800 |
---|---|---|
committer | Kyle Yan <kyan@codeaurora.org> | 2016-07-08 11:52:42 -0700 |
commit | aa0b21c907a888b2c425295675945581302cb95f (patch) | |
tree | 2c99a5570d027fcb891dce966af572c3a85d750c | |
parent | feb8b93c026935bd56e970cadb1ce4b04d55081d (diff) |
mfd: wcd9xxx-irq: check if wcd9xxx_res irq is 0 before using it
During SSR, wcd9xxx_res irq lock is destroyed as part of resource
cleanup. If driver tries to access wcd9xxx_res irq lock before it's
initialized, it could cause crash. Check if wcd9xxx_res irq is 0
before using it to avoid crash.
CRs-Fixed: 1003482
Change-Id: I959caf7b305e965b84e8204168194bbfda72dc52
Signed-off-by: Meng Wang <mwang@codeaurora.org>
-rw-r--r-- | drivers/mfd/wcd9xxx-irq.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/mfd/wcd9xxx-irq.c b/drivers/mfd/wcd9xxx-irq.c index 8024fab80295..1b93c83ae98e 100644 --- a/drivers/mfd/wcd9xxx-irq.c +++ b/drivers/mfd/wcd9xxx-irq.c @@ -390,18 +390,21 @@ void wcd9xxx_free_irq(struct wcd9xxx_core_resource *wcd9xxx_res, void wcd9xxx_enable_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq) { - enable_irq(phyirq_to_virq(wcd9xxx_res, irq)); + if (wcd9xxx_res->irq) + enable_irq(phyirq_to_virq(wcd9xxx_res, irq)); } void wcd9xxx_disable_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq) { - disable_irq_nosync(phyirq_to_virq(wcd9xxx_res, irq)); + if (wcd9xxx_res->irq) + disable_irq_nosync(phyirq_to_virq(wcd9xxx_res, irq)); } void wcd9xxx_disable_irq_sync( struct wcd9xxx_core_resource *wcd9xxx_res, int irq) { - disable_irq(phyirq_to_virq(wcd9xxx_res, irq)); + if (wcd9xxx_res->irq) + disable_irq(phyirq_to_virq(wcd9xxx_res, irq)); } static int wcd9xxx_irq_setup_downstream_irq( @@ -551,6 +554,7 @@ void wcd9xxx_irq_exit(struct wcd9xxx_core_resource *wcd9xxx_res) disable_irq_wake(wcd9xxx_res->irq); free_irq(wcd9xxx_res->irq, wcd9xxx_res); /* Release parent's of node */ + wcd9xxx_res->irq = 0; wcd9xxx_irq_put_upstream_irq(wcd9xxx_res); } mutex_destroy(&wcd9xxx_res->irq_lock); |