Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37512bc7 authored by Meng Wang's avatar Meng Wang
Browse files

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: default avatarMeng Wang <mwang@codeaurora.org>
parent fb8a39c1
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -388,17 +388,20 @@ void wcd9xxx_free_irq(struct wcd9xxx_core_resource *wcd9xxx_res,

void wcd9xxx_enable_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int 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)
{
	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)
{
	if (wcd9xxx_res->irq)
		disable_irq(phyirq_to_virq(wcd9xxx_res, irq));
}

@@ -559,6 +562,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);