From patchwork Fri Feb 17 20:58:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 94171 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp346972qgi; Fri, 17 Feb 2017 12:59:07 -0800 (PST) X-Received: by 10.107.20.148 with SMTP id 142mr8085369iou.12.1487365146953; Fri, 17 Feb 2017 12:59:06 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h62si2309133itb.123.2017.02.17.12.59.06; Fri, 17 Feb 2017 12:59:06 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 6BE57634E7; Fri, 17 Feb 2017 20:59:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 3564662F4A; Fri, 17 Feb 2017 20:59:02 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A9210634C3; Fri, 17 Feb 2017 20:59:00 +0000 (UTC) Received: from mail-oi0-f46.google.com (mail-oi0-f46.google.com [209.85.218.46]) by lists.linaro.org (Postfix) with ESMTPS id ED0E362DC8 for ; Fri, 17 Feb 2017 20:58:58 +0000 (UTC) Received: by mail-oi0-f46.google.com with SMTP id y140so736030oie.1 for ; Fri, 17 Feb 2017 12:58:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gQsSPayGhHWcmSYNdsBPnEqoLUR+fEpBLXCrEn99Akg=; b=hfv6bXLpjLKpuR/pyEns7Icrzffgn8kZx3bt2UJXJlZJzSPuaYQn35Ucor72Ng9WsZ SExPHpjyAsIXc47r8IJNjLI+CfqSg9RSJCXM8OHFl/BjwTfaJ+NwMocF45KRn2215TFv Otn80kSSdU/CkMS6pGtFJZGxGSsGCZ/KtOWS6F9tQQB5tkrmDaSBlQPgNYkHSJ610T5S qKSc5JpWD9vl3McFdDyvwuazbonq59rx+Xmd0WllZS6ykOvWTFpJha6goK4vsaqJGXzk 0PgXu1UPeiRmYEzdy5BfYtWoiARiYhZGORkr0Stjq10FZv1g2W46jyUSwV4ceFxuSp9e n1Ow== X-Gm-Message-State: AMke39mzJfXcs8KoXJqb50ep08SDJMomgXpNGLNG++78340/yEE+TDGU6bwf9JxPxP+o9FVbFwQ= X-Received: by 10.202.85.7 with SMTP id j7mr2243272oib.137.1487365138498; Fri, 17 Feb 2017 12:58:58 -0800 (PST) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id c7sm4809256otb.55.2017.02.17.12.58.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Feb 2017 12:58:57 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Fri, 17 Feb 2017 14:58:54 -0600 Message-Id: <20170217205854.7946-1-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.12.0.rc1 Subject: [lng-odp] [API-NEXT PATCH] linux-generic: packet: avoid race condition in packet_free processing X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2892 by setting unshared_len prior to potentially freeing segments. Reported-by: Janne Peltonen Signed-off-by: Bill Fischofer --- platform/linux-generic/odp_packet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.12.0.rc1 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;