drivers: wifi: esp: Fix bug with net_pkt_unref in tx path
The driver should only call net_pkt_unref on packets that get successfully handled, ie where send/sendto return 0. If the packet cannot be handled, net_context layer still owns the packet and should take care or the unref. Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
This commit is contained in:
parent
ddb9f290e1
commit
edcee97346
1 changed files with 8 additions and 4 deletions
|
@ -290,9 +290,6 @@ out:
|
|||
NULL, 0U, false);
|
||||
k_sem_give(&dev->cmd_handler_data.sem_tx_lock);
|
||||
|
||||
net_pkt_unref(sock->tx_pkt);
|
||||
sock->tx_pkt = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -316,6 +313,9 @@ static void esp_send_work(struct k_work *work)
|
|||
ret);
|
||||
}
|
||||
|
||||
net_pkt_unref(sock->tx_pkt);
|
||||
sock->tx_pkt = NULL;
|
||||
|
||||
if (sock->send_cb) {
|
||||
sock->send_cb(sock->context, ret, sock->send_user_data);
|
||||
}
|
||||
|
@ -392,11 +392,15 @@ static int esp_sendto(struct net_pkt *pkt,
|
|||
ret = _sock_send(dev, sock);
|
||||
k_sched_unlock();
|
||||
|
||||
if (ret < 0) {
|
||||
if (ret == 0) {
|
||||
net_pkt_unref(sock->tx_pkt);
|
||||
} else {
|
||||
LOG_ERR("Failed to send data: link %d, ret %d", sock->link_id,
|
||||
ret);
|
||||
}
|
||||
|
||||
sock->tx_pkt = NULL;
|
||||
|
||||
if (cb) {
|
||||
cb(context, ret, user_data);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue