RDC phase optimization: correct the behavior in case of memory allocation failure

phase_wait did not check whether queuebuf_new_from_packetbuf() returns NULL. This potentially causes send_packet to behave incorrectly; the proper packet would not be sent out (because queuebuf_to_packetbuf(NULL) is a no-op). Instead, whatever has been left in the packet buffer by its previous user will be sent out.
This commit is contained in:
Atis Elsts 2014-04-22 15:41:36 +02:00
parent 902b21a326
commit b75f673801

View File

@ -219,6 +219,11 @@ phase_wait(const linkaddr_t *neighbor, rtimer_clock_t cycle_time,
if(buf_list == NULL) {
packetbuf_set_attr(PACKETBUF_ATTR_IS_CREATED_AND_SECURED, 1);
p->q = queuebuf_new_from_packetbuf();
if(p->q == NULL) {
/* memory allocation failed */
memb_free(&queued_packets_memb, p);
return PHASE_UNKNOWN;
}
}
p->mac_callback = mac_callback;
p->mac_callback_ptr = mac_callback_ptr;