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

Commit cdb150a5 authored by Chris Lew's avatar Chris Lew
Browse files

net: qrtr: Check for exisiting waiters



Some non-blocking clients may not wait for the OUT event from select or
poll before resending to a flow controlled port. Check for exisiting
waiters before allocating a new one so these clients do not exhaust the
memory pool.

Change-Id: I5fc40d5b1d1819ea5bf94438c04ee42b42639ebc
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent 885277a7
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -500,6 +500,12 @@ static int qrtr_tx_wait(struct qrtr_node *node, struct sockaddr_qrtr *to,
			break;
		}
		if (!ret) {
			list_for_each_entry(waiter, &flow->waiters, node) {
				if (waiter->sk == sk) {
					mutex_unlock(&node->qrtr_tx_lock);
					return -EAGAIN;
				}
			}
			waiter = kzalloc(sizeof(*waiter), GFP_KERNEL);
			if (!waiter) {
				mutex_unlock(&node->qrtr_tx_lock);
@@ -508,6 +514,8 @@ static int qrtr_tx_wait(struct qrtr_node *node, struct sockaddr_qrtr *to,
			waiter->sk = sk;
			sock_hold(sk);
			list_add_tail(&waiter->node, &flow->waiters);
			QRTR_INFO(node->ilc, "new waiter for [0x%x:0x%x]\n",
				  to->sq_node, to->sq_port);
			mutex_unlock(&node->qrtr_tx_lock);
			return -EAGAIN;
		}