gnrc_lorawan: fix undefined state when PSDU is NULL

This commit is contained in:
Jose Alamos 2021-06-24 15:03:17 +02:00
parent 2a1a2ee1d5
commit 71ddd3bd61
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9
2 changed files with 13 additions and 2 deletions

View File

@ -176,6 +176,17 @@ void gnrc_lorawan_radio_rx_timeout_cb(gnrc_lorawan_t *mac);
*/
void gnrc_lorawan_radio_tx_done_cb(gnrc_lorawan_t *mac);
/**
* @brief Indicate the MAC layer reception of a frame went wrong.
*
* @param[in] mac pointer to the MAC descriptor
*/
static inline void gnrc_lorawan_radio_rx_error_cb(gnrc_lorawan_t *mac)
{
/* The failed reception is seen by the MAC layer as an RX timeout */
gnrc_lorawan_radio_rx_timeout_cb(mac);
}
/**
* @brief Indicate the MAC layer that the timer was fired
*

View File

@ -180,13 +180,13 @@ static void _rx_done(gnrc_lorawan_t *mac)
DEBUG("_recv_lorawan: cannot allocate pktsnip.\n");
/* Discard packet on netdev device */
dev->driver->recv(dev, NULL, bytes_expected, NULL);
gnrc_lorawan_radio_rx_done_cb(mac, NULL, 0);
gnrc_lorawan_radio_rx_error_cb(mac);
return;
}
nread = dev->driver->recv(dev, pkt->data, bytes_expected, &rx_info);
if (nread <= 0) {
gnrc_pktbuf_release(pkt);
gnrc_lorawan_radio_rx_done_cb(mac, NULL, 0);
gnrc_lorawan_radio_rx_error_cb(mac);
return;
}