Skip to content

Commit

Permalink
net: mqtt: Add missing mutex_unlock
Browse files Browse the repository at this point in the history
mqtt_connect was not releasing mutex after successfull connection.
Reworked the code to have a single exit path with mutex unlock.

Signed-off-by: Robert Lubos <[email protected]>
  • Loading branch information
rlubos authored and nashif committed Nov 28, 2018
1 parent 21224a9 commit a26db60
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions subsys/net/lib/mqtt_sock/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,14 @@ int mqtt_connect(struct mqtt_client *client)
}

err_code = client_connect(client);

error:
if (err_code < 0) {
err_code = -ECONNREFUSED;
goto error;
client_reset(client);
}

return 0;

error:
client_reset(client);
mqtt_mutex_unlock(client);

return err_code;
}

Expand Down

0 comments on commit a26db60

Please sign in to comment.