From 1804730c0e36da300d99aca32ecd0cf8f9ee4fac Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Mon, 1 Apr 2019 11:46:42 +0200 Subject: [PATCH] mrf24j40: don't load data if iol->iol_len == 0 --- drivers/mrf24j40/mrf24j40_netdev.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/mrf24j40/mrf24j40_netdev.c b/drivers/mrf24j40/mrf24j40_netdev.c index 289bd6a5bd..b3289883f1 100644 --- a/drivers/mrf24j40/mrf24j40_netdev.c +++ b/drivers/mrf24j40/mrf24j40_netdev.c @@ -71,13 +71,17 @@ static int _send(netdev_t *netdev, const iolist_t *iolist) /* load packet data into FIFO */ for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) { - /* current packet data + FCS too long */ - if ((len + iol->iol_len + 2) > IEEE802154_FRAME_LEN_MAX) { - DEBUG("[mrf24j40] error: packet too large (%u byte) to be send\n", - (unsigned)len + 2); - return -EOVERFLOW; + /* Check if there is data to copy, prevents assertion failure in the + * SPI peripheral if there is no data to copy */ + if (iol->iol_len) { + /* current packet data + FCS too long */ + if ((len + iol->iol_len + 2) > IEEE802154_FRAME_LEN_MAX) { + DEBUG("[mrf24j40] error: packet too large (%u byte) to be send\n", + (unsigned)len + 2); + return -EOVERFLOW; + } + len = mrf24j40_tx_load(dev, iol->iol_base, iol->iol_len, len); } - len = mrf24j40_tx_load(dev, iol->iol_base, iol->iol_len, len); /* only on first iteration: */ if (iol == iolist) { dev->header_len = len;