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

Commit aff4c897 authored by Arun Kumar Neelakantam's avatar Arun Kumar Neelakantam
Browse files

net: qrtr: Fix missing resume_tx notification



Race between qrtr_tx_resume() handling rx_resume and qrtr_tx_wait()
adding the waiter to waitqueue causes qmi client to miss the resume_tx.

Add waiter while sending confirm_rx to avoid the race condition.

Change-Id: I628a8460f1a2a0a671e1006177c36257286f8746
Signed-off-by: default avatarArun Kumar Neelakantam <aneela@codeaurora.org>
parent d8f81fe4
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -452,18 +452,8 @@ static int qrtr_tx_wait(struct qrtr_node *node, struct sockaddr_qrtr *to,
				timeo);
		if (ret < 0)
			return ret;
		if (!ret) {
			waiter = kzalloc(sizeof(*waiter), GFP_KERNEL);
			if (!waiter)
				return -ENOMEM;
			waiter->sk = sk;
			sock_hold(sk);

			mutex_lock(&node->qrtr_tx_lock);
			list_add_tail(&waiter->node, &flow->waiters);
			mutex_unlock(&node->qrtr_tx_lock);
		if (!ret)
			return -EAGAIN;
		}

		if (!node->ep)
			return -EPIPE;
@@ -478,6 +468,17 @@ static int qrtr_tx_wait(struct qrtr_node *node, struct sockaddr_qrtr *to,
		mutex_unlock(&node->qrtr_tx_lock);
	}

	if (confirm_rx) {
		waiter = kzalloc(sizeof(*waiter), GFP_KERNEL);
		if (!waiter)
			return -ENOMEM;
		waiter->sk = sk;
		sock_hold(sk);

		mutex_lock(&node->qrtr_tx_lock);
		list_add_tail(&waiter->node, &flow->waiters);
		mutex_unlock(&node->qrtr_tx_lock);
	}
	return confirm_rx;
}

@@ -568,9 +569,11 @@ static void qrtr_node_assign(struct qrtr_node *node, unsigned int nid)
		node->nid = nid;
	up_write(&qrtr_node_lock);

	if (!node->ilc) {
		snprintf(name, sizeof(name), "qrtr_%d", nid);
		node->ilc = ipc_log_context_create(QRTR_LOG_PAGE_CNT, name, 0);
	}
}

/**
 * qrtr_endpoint_post() - post incoming data