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

Commit 911d8887 authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Gerrit - the friendly Code Review server
Browse files

power: qpnp-qg: Fix the possible deadlock during suspend



There is a possible deadlock with two-threads (suspend callback
and sleep_work) are holding/waiting on the same mutex.

Fix this by cancelling the work before the mutex is held by
the suspend callback.

Change-Id: I65882067783100e7b9ecdc1e697b93948945b41b
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 40a26795
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -4310,7 +4310,6 @@ static int process_suspend(struct qpnp_qg *chip)
		return 0;

	cancel_delayed_work_sync(&chip->ttf->ttf_work);
	cancel_delayed_work_sync(&chip->qg_sleep_exit_work);

	chip->suspend_data = false;

@@ -4477,6 +4476,9 @@ static int qpnp_qg_suspend_noirq(struct device *dev)
	int rc;
	struct qpnp_qg *chip = dev_get_drvdata(dev);

	/* cancel any pending sleep_exit work */
	cancel_delayed_work_sync(&chip->qg_sleep_exit_work);

	mutex_lock(&chip->data_lock);

	rc = process_suspend(chip);