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

Commit 76cd6ea2 authored by Chris Lew's avatar Chris Lew Committed by Gerrit - the friendly Code Review server
Browse files

mailbox: msm_qmp: Fix qmp shutdown logic



If a mailbox fails to initialize correctly during the connecting stage,
the mailbox framework will call shutdown. The current logic incorrectly
increments ref counts when shutdown is called on a failing mailbox. Add
the correct handling for the connecting stages.

Change-Id: I9314aed833a9eecaaff9860e3261e89f6a7aa9c7
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent 56be5bb9
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -391,12 +391,21 @@ static void qmp_shutdown(struct mbox_chan *chan)
	struct qmp_mbox *mbox = chan->con_priv;

	mutex_lock(&mbox->state_lock);
	mbox->num_shutdown++;
	if (mbox->num_shutdown < mbox->num_assigned) {
		mutex_unlock(&mbox->state_lock);
		return;
	if (mbox->local_state <= LINK_CONNECTED) {
		mbox->num_assigned--;
		goto out;
	}

	if (mbox->local_state == LOCAL_CONNECTING) {
		mbox->num_assigned--;
		mbox->local_state = LINK_CONNECTED;
		goto out;
	}

	mbox->num_shutdown++;
	if (mbox->num_shutdown < mbox->num_assigned)
		goto out;

	if (mbox->local_state != LINK_DISCONNECTED) {
		mbox->local_state = LOCAL_DISCONNECTING;
		set_mcore_ch(mbox, QMP_MBOX_CH_DISCONNECTED);
@@ -404,6 +413,7 @@ static void qmp_shutdown(struct mbox_chan *chan)
	}
	mbox->num_shutdown = 0;
	mbox->num_assigned = 0;
out:
	mutex_unlock(&mbox->state_lock);
}