net: lwm2m: fix packet leak in timeout work

When a packet expires after the pending retries we call
lwm2m_release_message() to free up resources.  This includes
cleanup of the pending structure which calls net_pkt_unref on
the pending packet.  This would normally free up the packet
memory.  However, earlier in the pending processing we add a ref
to the packet so that normal send processing doesn't free up
the memory.   This meant we were leaking packet memory every
time we had an expiration due to timeout.

Let's do an unref prior to calling lwm2m_release_message() to
make sure the packet memory is freed correctly.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
This commit is contained in:
Michael Scott 2017-09-08 08:32:16 -07:00 committed by Anas Nashif
commit 0b0fd5515d

View file

@ -2725,6 +2725,8 @@ static void retransmit_request(struct k_work *work)
msg->message_timeout_cb(msg);
}
/* final unref to release pkt */
net_pkt_unref(pending->pkt);
lwm2m_release_message(msg);
return;
}