Skip to content

Commit 8b1aa26

Browse files
Parthasarathy Bhuvaragangregkh
authored andcommitted
tipc: ignore requests when the connection state is not CONNECTED
[ Upstream commit 4c887aa65d38633885010277f3482400681be719 ] In tipc_conn_sendmsg(), we first queue the request to the outqueue followed by the connection state check. If the connection is not connected, we should not queue this message. In this commit, we reject the messages if the connection state is not CF_CONNECTED. Acked-by: Ying Xue <ying.xue@windriver.com> Acked-by: Jon Maloy <jon.maloy@ericsson.com> Tested-by: John Thompson <thompa.atl@gmail.com> Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 77d2b8d commit 8b1aa26

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

net/tipc/server.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,11 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid,
452452
if (!con)
453453
return -EINVAL;
454454

455+
if (!test_bit(CF_CONNECTED, &con->flags)) {
456+
conn_put(con);
457+
return 0;
458+
}
459+
455460
e = tipc_alloc_entry(data, len);
456461
if (!e) {
457462
conn_put(con);
@@ -465,12 +470,8 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid,
465470
list_add_tail(&e->list, &con->outqueue);
466471
spin_unlock_bh(&con->outqueue_lock);
467472

468-
if (test_bit(CF_CONNECTED, &con->flags)) {
469-
if (!queue_work(s->send_wq, &con->swork))
470-
conn_put(con);
471-
} else {
473+
if (!queue_work(s->send_wq, &con->swork))
472474
conn_put(con);
473-
}
474475
return 0;
475476
}
476477

@@ -494,7 +495,7 @@ static void tipc_send_to_sock(struct tipc_conn *con)
494495
int ret;
495496

496497
spin_lock_bh(&con->outqueue_lock);
497-
while (1) {
498+
while (test_bit(CF_CONNECTED, &con->flags)) {
498499
e = list_entry(con->outqueue.next, struct outqueue_entry,
499500
list);
500501
if ((struct list_head *) e == &con->outqueue)

0 commit comments

Comments
 (0)