From c3575fbd2e9b874476d2da8ca09993e686cd2ad9 Mon Sep 17 00:00:00 2001 From: Wojciech Slenska Date: Wed, 19 Apr 2023 11:33:31 +0200 Subject: [PATCH] net: sockets: fix POLLOUT for offloaded iface For offloaded iface net_tcp_get is never called, so context->tcp is always NULL. In that case net_tcp_tx_sem_get will return wrong pointer. For pollout k_poll will be called with NULL semph, which cause HardFault. Signed-off-by: Wojciech Slenska --- subsys/net/lib/sockets/sockets.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/subsys/net/lib/sockets/sockets.c b/subsys/net/lib/sockets/sockets.c index 16d6e879f86..9e86a56ef10 100644 --- a/subsys/net/lib/sockets/sockets.c +++ b/subsys/net/lib/sockets/sockets.c @@ -738,7 +738,8 @@ static int send_check_and_wait(struct net_context *ctx, int status, if (status == -EAGAIN) { if (IS_ENABLED(CONFIG_NET_NATIVE_TCP) && - net_context_get_type(ctx) == SOCK_STREAM) { + net_context_get_type(ctx) == SOCK_STREAM && + !net_if_is_ip_offloaded(net_context_get_iface(ctx))) { struct k_poll_event event; k_poll_event_init(&event, @@ -1520,7 +1521,8 @@ static int zsock_poll_prepare_ctx(struct net_context *ctx, if (pfd->events & ZSOCK_POLLOUT) { if (IS_ENABLED(CONFIG_NET_NATIVE_TCP) && - net_context_get_type(ctx) == SOCK_STREAM) { + net_context_get_type(ctx) == SOCK_STREAM && + !net_if_is_ip_offloaded(net_context_get_iface(ctx))) { if (*pev == pev_end) { return -ENOMEM; } @@ -1565,7 +1567,8 @@ static int zsock_poll_update_ctx(struct net_context *ctx, } if (pfd->events & ZSOCK_POLLOUT) { if (IS_ENABLED(CONFIG_NET_NATIVE_TCP) && - net_context_get_type(ctx) == SOCK_STREAM) { + net_context_get_type(ctx) == SOCK_STREAM && + !net_if_is_ip_offloaded(net_context_get_iface(ctx))) { if ((*pev)->state != K_POLL_STATE_NOT_READY && !sock_is_eof(ctx) && (net_context_get_state(ctx) == NET_CONTEXT_CONNECTED)) {