Skip to content

Commit

Permalink
net: mqtt: Fix possible socket leak with websocket transport
Browse files Browse the repository at this point in the history
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: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 4625fa7)
  • Loading branch information
rlubos authored and henrikbrixandersen committed Jul 9, 2024
1 parent 4769dbb commit ace6e44
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions subsys/net/lib/mqtt/mqtt_transport_websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ace6e44

Please sign in to comment.