Skip to content

Commit 65f1ab3

Browse files
committed
eth: remove double pbuf remove and double free
When the packet dest does not match the iface addr and promisc is off We would try and remove packet from pbuf again and double free
1 parent 7e8d832 commit 65f1ab3

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/interfaces/csp_if_eth.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
bool eth_debug = false;
2222

23-
bool csp_eth_pack_header(csp_eth_header_t * buf,
23+
bool csp_eth_pack_header(csp_eth_header_t * buf,
2424
uint16_t packet_id, uint16_t src_addr,
2525
uint16_t seg_size, uint16_t packet_length) {
2626

@@ -52,7 +52,7 @@ static bool csp_if_eth_unpack_header(csp_eth_header_t * buf,
5252
/**
5353
* Address resolution (ARP)
5454
* All received (ETH MAC, CSP src) are recorded and used to map destination address to MAC addresses,
55-
* used in uni-cast. Until a packet from a CSP address has been received, ETH broadcast is used to this address.
55+
* used in uni-cast. Until a packet from a CSP address has been received, ETH broadcast is used to this address.
5656
*/
5757

5858
#define ARP_MAX_ENTRIES 10
@@ -66,7 +66,7 @@ typedef struct arp_list_entry_s {
6666
static arp_list_entry_t arp_array[ARP_MAX_ENTRIES];
6767
static size_t arp_used = 0;
6868

69-
static arp_list_entry_t * arp_list = 0;
69+
static arp_list_entry_t * arp_list = 0;
7070

7171
static arp_list_entry_t * arp_alloc(void) {
7272

@@ -157,7 +157,7 @@ int csp_eth_rx(csp_iface_t * iface, csp_eth_header_t * eth_frame, uint32_t recei
157157

158158
if (seg_size == 0 || seg_size > CSP_ETH_FRAME_SIZE_MAX) {
159159
iface->frame++;
160-
csp_print("eth rx seg_size of %u bytes is invalid\n");
160+
csp_print("eth rx seg_size of %u bytes is invalid\n", (unsigned)seg_size);
161161
return CSP_ERR_INVAL;
162162
}
163163

@@ -230,7 +230,6 @@ int csp_eth_rx(csp_iface_t * iface, csp_eth_header_t * eth_frame, uint32_t recei
230230
csp_eth_arp_set_addr(eth_frame->ether_shost, packet->id.src);
231231

232232
if (packet->id.dst != iface->addr && !ifdata->promisc) {
233-
csp_eth_pbuf_free(ifdata, packet, true, task_woken);
234233
(task_woken) ? csp_buffer_free_isr(packet) : csp_buffer_free(packet);
235234
return CSP_ERR_NONE;
236235
}

0 commit comments

Comments
 (0)