From 4d5812eded43a8c6adcff40d774260e103fb13e8 Mon Sep 17 00:00:00 2001 From: Alexander Podshivalov Date: Thu, 29 Oct 2020 18:45:29 +0300 Subject: [PATCH] pkg/semtech-loramac: check return value of recv() in NETDEV_EVENT_RX_COMPLETE --- pkg/semtech-loramac/contrib/semtech_loramac.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/semtech-loramac/contrib/semtech_loramac.c b/pkg/semtech-loramac/contrib/semtech_loramac.c index b74e425f4c..869970ef09 100644 --- a/pkg/semtech-loramac/contrib/semtech_loramac.c +++ b/pkg/semtech-loramac/contrib/semtech_loramac.c @@ -539,13 +539,15 @@ static void _semtech_loramac_event_cb(netdev_t *dev, netdev_event_t event) case NETDEV_EVENT_RX_COMPLETE: { - size_t len; + int len; uint8_t radio_payload[SX127X_RX_BUFFER_SIZE]; len = dev->driver->recv(dev, NULL, 0, 0); - dev->driver->recv(dev, radio_payload, len, &packet_info); - semtech_loramac_radio_events.RxDone(radio_payload, - len, packet_info.rssi, - packet_info.snr); + if (len > 0) { + dev->driver->recv(dev, radio_payload, len, &packet_info); + semtech_loramac_radio_events.RxDone(radio_payload, + len, packet_info.rssi, + packet_info.snr); + } /* len could be -EBADMSG, in which case a CRC error message will be received shortly */ break; } case NETDEV_EVENT_RX_TIMEOUT: