[PATCH kvmtool] net/uip: Avoid deadlock in uip_tcp_socket_free()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The function uip_tcp_socket_free() is called with the sk lock held, but
then goes on to call uip_tcp_socket_close() which attempts to aquire the
lock a second time, triggering a deadlock if there are outstanding TCP
connections.

Rather than call uip_tcp_socket_close(), just do the cleanup directly in
uip_tcp_socket_free().

Fixes: d87b503f4d6e ("net/uip: Add exit function")
Signed-off-by: Steven Price <steven.price@xxxxxxx>
---
 net/uip/tcp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/uip/tcp.c b/net/uip/tcp.c
index 8e0ad5235240..2a6a8f5265d9 100644
--- a/net/uip/tcp.c
+++ b/net/uip/tcp.c
@@ -109,8 +109,12 @@ static void uip_tcp_socket_free(struct uip_tcp_socket *sk)
 		pthread_join(sk->thread, NULL);
 	}
 
-	sk->write_done = sk->read_done = 1;
-	uip_tcp_socket_close(sk, SHUT_RDWR);
+	shutdown(sk->fd, SHUT_RDWR);
+	close(sk->fd);
+	list_del(&sk->list);
+
+	free(sk->buf);
+	free(sk);
 }
 
 static int uip_tcp_payload_send(struct uip_tcp_socket *sk, u8 flag, u16 payload_len)
-- 
2.43.0





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux