Skip to content

Commit

Permalink
modem: fix socket descriptor leak
Browse files Browse the repository at this point in the history
z_free_fd() is called twice then you close(). For example in ublox sara
r4 driver offload_close() calls modem_socket_put() where z_free_fd() is
called first time. Then this same function is called another time in
socket.c in z_impl_zsock_close() after this function has called
offload_close() in ublox sara r4 driver. This causes socket
descriptor leak.

Fixes #26819

Signed-off-by: Akseli Peltola <[email protected]>
  • Loading branch information
peltsu authored and jukkar committed Jan 7, 2021
1 parent b34d055 commit 3bcb1ef
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion drivers/modem/modem_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ void modem_socket_put(struct modem_socket_config *cfg, int sock_fd)

k_sem_take(&cfg->sem_lock, K_FOREVER);

z_free_fd(sock->sock_fd);
sock->id = cfg->base_socket_num - 1;
sock->sock_fd = -1;
sock->is_waiting = false;
Expand Down

0 comments on commit 3bcb1ef

Please sign in to comment.