From b64e524d9d39eff7198f09466108dabccfe66e3a Mon Sep 17 00:00:00 2001 From: Andrei Carp Date: Mon, 15 Jul 2013 15:52:53 +0300 Subject: [PATCH] Bug #754. Fixed the memory leaking when device is busy. --- stack/pico_stack.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/stack/pico_stack.c b/stack/pico_stack.c index 184350990..fd90ef47f 100644 --- a/stack/pico_stack.c +++ b/stack/pico_stack.c @@ -333,6 +333,7 @@ static struct pico_eth *pico_ethernet_mcast_translate(struct pico_frame *f, uint int pico_ethernet_send(struct pico_frame *f) { struct pico_eth *dstmac = NULL; + int ret = -1; if (IS_IPV6(f)) { /*TODO: Neighbor solicitation */ @@ -366,18 +367,22 @@ int pico_ethernet_send(struct pico_frame *f) hdr->proto = PICO_IDETH_IPV4; if(!memcmp(hdr->daddr, hdr->saddr, PICO_SIZE_ETH)){ dbg("sending out packet destined for our own mac\n"); - return pico_ethernet_receive(f); + return pico_ethernet_receive(f); }else if(IS_LIMITED_BCAST(f)){ - return pico_device_broadcast(f); + ret = pico_device_broadcast(f); }else { - return f->dev->send(f->dev, f->start, f->len); + ret = f->dev->send(f->dev, f->start, f->len); /* Frame is discarded after this return by the caller */ } + + if(!ret) pico_frame_discard(f); + return ret; } else { return -1; } } /* End IPV4 ethernet addressing */ return -1; + } void pico_store_network_origin(void *src, struct pico_frame *f)