diff --git a/arch/arm/src/nrf91/nrf91_modem_sock.c b/arch/arm/src/nrf91/nrf91_modem_sock.c index 0416d21683..80c8638e03 100644 --- a/arch/arm/src/nrf91/nrf91_modem_sock.c +++ b/arch/arm/src/nrf91/nrf91_modem_sock.c @@ -891,12 +891,6 @@ static int nrf91_usrsock_recvfrom_handler(struct nrf91_usrsock_s *usrsock, buflen = sizeof(usrsock->out) - sizeof(*ack) - inaddrlen; } - if (outaddrlen != 0) - { - tmp = (struct sockaddr *)(ack + 1); - nx2nrf_sockaddr(tmp, (struct nrf_sockaddr *)&address); - } - ret = nrf_recvfrom(req->usockid, (void *)(ack + 1) + inaddrlen, buflen, @@ -909,6 +903,12 @@ static int nrf91_usrsock_recvfrom_handler(struct nrf91_usrsock_s *usrsock, ret = -errno; } + if (outaddrlen != 0) + { + tmp = (struct sockaddr *)(ack + 1); + nrf2nx_sockaddr((struct nrf_sockaddr *)&address, tmp); + } + recvlen = ret; if (ret > 0 && outaddrlen < inaddrlen)