diff mbox

[API-NEXT] linux-generic: packet: avoid race condition in packet_free processing

Message ID 20170217205854.7946-1-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Feb. 17, 2017, 8:58 p.m. UTC
Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2892 by setting
unshared_len prior to potentially freeing segments.

Reported-by: Janne Peltonen <janne.peltonen@nokia.com>
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
 platform/linux-generic/odp_packet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.12.0.rc1
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 81bbcedd..5c28a1fd 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -693,10 +693,10 @@  static inline void packet_free(odp_packet_hdr_t *pkt_hdr)
 			buffer_free_multi((odp_buffer_t *)
 					  &pkt_hdr->buf_hdr.handle.handle, 1);
 		} else {
-			free_bufs(pkt_hdr, 0, num_seg);
-
 			if (ref_count == 2)
 				pkt_hdr->unshared_len = pkt_hdr->frame_len;
+
+			free_bufs(pkt_hdr, 0, num_seg);
 		}
 
 		pkt_hdr = ref_hdr;