diff --git a/net/can/can_sendmsg.c b/net/can/can_sendmsg.c index 5f13e99b88afc..9dc764dc584f3 100644 --- a/net/can/can_sendmsg.c +++ b/net/can/can_sendmsg.c @@ -109,8 +109,8 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, /* Copy the packet data into the device packet buffer and send it */ int ret = devif_send(dev, pstate->snd_buffer, - pstate->snd_buflen, 0); - dev->d_len = dev->d_sndlen; + pstate->snd_buflen + pstate->pr_msglen, 0); + dev->d_len = dev->d_sndlen - pstate->pr_msglen; if (ret <= 0) { pstate->snd_sent = ret; @@ -122,7 +122,6 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev, { memcpy(dev->d_buf + pstate->snd_buflen, pstate->pr_msgbuf, pstate->pr_msglen); - dev->d_sndlen = pstate->snd_buflen + pstate->pr_msglen; } } diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c index 2d12606e9429f..6453e85a5f777 100644 --- a/net/devif/devif_poll.c +++ b/net/devif/devif_poll.c @@ -1032,6 +1032,7 @@ static int devif_poll_callback(FAR struct net_driver_s *dev) int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) { + unsigned len; uint16_t llhdrlen; FAR uint8_t *buf; int bstop; @@ -1054,7 +1055,8 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) { /* Copy iob to flat buffer */ - iob_copyout(buf, dev->d_iob, dev->d_len, -llhdrlen); + len = MAX(dev->d_len, dev->d_sndlen); + iob_copyout(buf, dev->d_iob, len, -llhdrlen); /* Restore flat buffer pointer */