diff --git a/sys/net/gnrc/link_layer/lwmac/lwmac.c b/sys/net/gnrc/link_layer/lwmac/lwmac.c index d9627a0e79..ef21508d5a 100644 --- a/sys/net/gnrc/link_layer/lwmac/lwmac.c +++ b/sys/net/gnrc/link_layer/lwmac/lwmac.c @@ -524,8 +524,6 @@ static void _rx_management(gnrc_netif2_t *netif) static void _tx_management_stopped(gnrc_netif2_t *netif) { - gnrc_pktsnip_t *pkt; - /* If there is packet remaining for retransmission, * retransmit it (i.e., the retransmission scheme of LWMAC). */ if (netif->mac.tx.packet != NULL) { @@ -536,6 +534,8 @@ static void _tx_management_stopped(gnrc_netif2_t *netif) gnrc_lwmac_tx_update(netif); } else { + gnrc_pktsnip_t *pkt; + if ((pkt = gnrc_priority_pktqueue_pop( &netif->mac.tx.current_neighbor->queue))) { netif->mac.tx.tx_retry_count = 0; diff --git a/sys/net/gnrc/link_layer/lwmac/tx_state_machine.c b/sys/net/gnrc/link_layer/lwmac/tx_state_machine.c index c201b50968..ae68acb68d 100644 --- a/sys/net/gnrc/link_layer/lwmac/tx_state_machine.c +++ b/sys/net/gnrc/link_layer/lwmac/tx_state_machine.c @@ -378,6 +378,7 @@ static bool _send_data(gnrc_netif2_t *netif) gnrc_pktsnip_t *pkt = netif->mac.tx.packet; gnrc_pktsnip_t *pkt_payload; + assert(pkt != NULL); /* Enable Auto ACK again */ netopt_enable_t autoack = NETOPT_ENABLE; netif->dev->driver->set(netif->dev, NETOPT_AUTOACK, @@ -451,9 +452,7 @@ static bool _send_data(gnrc_netif2_t *netif) int res = _gnrc_lwmac_transmit(netif, pkt); if (res < 0) { LOG_ERROR("ERROR: [LWMAC-tx] Send data failed."); - if (pkt != NULL) { - gnrc_pktbuf_release(pkt); - } + gnrc_pktbuf_release(pkt); /* clear packet point to avoid TX retry */ netif->mac.tx.packet = NULL; return false;