From patchwork Thu May 11 22:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 99685 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp15888qge; Thu, 11 May 2017 15:06:33 -0700 (PDT) X-Received: by 10.55.25.80 with SMTP id k77mr764529qkh.294.1494540393877; Thu, 11 May 2017 15:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494540393; cv=none; d=google.com; s=arc-20160816; b=egwJ7sqzw/cQExB8Ba2lEaefdi8FpWOEhv+wykccpfWw0bykNxbRpfSiGw4S8a2BEs 71SCHz/Q4LNh5raJV8QtvBPA/wrUlGfTw0e2PrTJSzstjSxq67jiE4tGVO/KdLsxpy6L 0SXY6qYbb/7kgbTG62i5Pcxy77Mk1QiUGI7Hc5aksOE+6Ep3pwKezDWYplPMEVZvJO9o SU/fdtmhEujTypHKWYeVG31uST5p4Pz3HVl7k5iJJQMQJ4cCtIay03h4Ly5RfT8JQ6me CiTNknMfuIwCvrNdfV9pCwczg+whjlepHS5KkxTJIPOGWFxFbggIxu6Mlk9afya8+YMI i7fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=xe9+br7PBCRN4NF0cFvajPaJzqkKVg5PRb+vlR4zvw8=; b=uCw27i4nWBxR2oWdUrHXVuhyceS1taUdWVoOJyOq4J15UFw1oe0Av1EK1TQcnuMCUL KZIFyy21R3HWeinxUl3iDkW+ZbD9I7Mewy5EP28gJoLrw1nU5ZwhmIFl8kMQfxUfufq8 ecsDbrjP7zp6oaBAj0wsg+2CFb2kJvtigbHLSBi1o8JksUBTWLZeOvOU3T+CYXLFmJX9 mtYanBhOpnIhr8U/trXfCEvFwxvnGxzcxzBEVx/JSOulUKdfcGTwOExqv3N87UpKpfjT 3xWrn9mRpq+JhsctR3/QNWKOb2g9G7jry/iMR3SgNqFOGZ03K6h7bYsR0fwG88PtoJKG 2N8A== ARC-Authentication-Results: i=1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 12si1322397qkp.330.2017.05.11.15.06.33; Thu, 11 May 2017 15:06:33 -0700 (PDT) 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 91F8760889; Thu, 11 May 2017 22:06:33 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 3FD6460D2D; Thu, 11 May 2017 22:01:41 +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 5B1CF6087A; Thu, 11 May 2017 22:01:07 +0000 (UTC) Received: from forward2o.cmail.yandex.net (forward2o.cmail.yandex.net [37.9.109.243]) by lists.linaro.org (Postfix) with ESMTPS id B866660677 for ; Thu, 11 May 2017 22:01:05 +0000 (UTC) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:8]) by forward2o.cmail.yandex.net (Yandex) with ESMTP id 019352103B for ; Fri, 12 May 2017 01:01:04 +0300 (MSK) Received: from smtp3p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp3p.mail.yandex.net (Yandex) with ESMTP id CD16A1320042 for ; Fri, 12 May 2017 01:01:03 +0300 (MSK) Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id yyhcZmfGaE-13Um8Ceh; Fri, 12 May 2017 01:01:03 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 12 May 2017 01:00:06 +0300 Message-Id: <1494540010-25779-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494540010-25779-1-git-send-email-odpbot@yandex.ru> References: <1494540010-25779-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 28 Subject: [lng-odp] [PATCH API-NEXT v3 6/10] linux-generic: crypto: don't leak sessions if creation fails 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" From: Dmitry Eremin-Solenikov We should free allocated session in odp_crypto_session_create() error paths, so that the session is not leaked. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 28 (lumag:ipsec) ** https://github.com/Linaro/odp/pull/28 ** Patch: https://github.com/Linaro/odp/pull/28.patch ** Base sha: 900dd9e2d3d2ae751ab2bc4e11dbd48ea7ed7030 ** Merge commit sha: 1589f97414ab144b3cb1e65667d311783fdba670 **/ platform/linux-generic/odp_crypto.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index a0f3f7e..dfeb9f3 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -682,6 +682,7 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, if (session->p.iv.data) { if (session->p.iv.length > MAX_IV_LEN) { ODP_DBG("Maximum IV length exceeded\n"); + free_session(session); return -1; } @@ -732,6 +733,7 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, /* Check result */ if (rc) { *status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER; + free_session(session); return -1; } @@ -778,6 +780,7 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, /* Check result */ if (rc) { *status = ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH; + free_session(session); return -1; }