Commit fcd271d0 authored by Robert Lubos's avatar Robert Lubos Committed by Fabio Baltieri
Browse files

net: mqtt: Fix possible socket leak with websocket transport

In case underlying TCP/TLS connection is already down, the
websocket_disconnect() call is expected to fail, as it involves
communication. Therefore, mqtt_client_websocket_disconnect() should not
quit early in such cases, as it could lead to an underlying socket leak.

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 4625fa71)
parent b5d53e92
Loading
Loading
Loading
Loading
+1 −2
Changes for subsys/net/lib/mqtt/mqtt_transport_websocket.c: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -174,8 +174,7 @@ int mqtt_client_websocket_disconnect(struct mqtt_client *client)

	ret = websocket_disconnect(client->transport.websocket.sock);
	if (ret < 0) {
		NET_ERR("Websocket disconnect failed (%d)", ret);
		return ret;
		NET_DBG("Websocket disconnect failed (%d)", ret);
	}

	if (client->transport.type == MQTT_TRANSPORT_NON_SECURE_WEBSOCKET) {