From patchwork Thu May 11 23:00:05 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: 99695 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp36511qge; Thu, 11 May 2017 16:07:05 -0700 (PDT) X-Received: by 10.55.27.18 with SMTP id b18mr988195qkb.142.1494544025173; Thu, 11 May 2017 16:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494544025; cv=none; d=google.com; s=arc-20160816; b=yrOvg1TXK2gFbcGTigZM2dp5zobSOc5Pi2mwGTfk6nHvaCeD7OL5niHW1oazH93vCm 27i7g7kx0XFDh+T8JQBxk7vNH6UQxskgSpd0NIsL+/Ts6sWnF9ScLa2iXOfI8q82+HtE T9+jLK3+vqRIqptGHcBDvHPSnPRevfi7jKW/ZjL4p82C9TZIaPu1qlj0iLjAVitq+Ow9 4qcMZjgnM65WnDeWL4fMVn8YBZeqGk9XuA8tWCTTiFAM9HjzyhIze5crpfn/vNYluWhp eLRXPsg8Mdqh21NmD6lgzsCfh63ksC0OT3vQcDvX37A2duVnPaNNZlcS5NPn4Dg3L3Dt kZ3g== 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=vjszeHpX0RYrvyHn7ETtFxbEHP1yrrAdo790+0KBnBw=; b=ZgwElTw0sp78Db+jc4j+DeCixU2MrZ2EwMYaa4E4FdqPRgWcbN0X89W8XaLgEsF2q5 cjNQEu3rbpJOmsgTyPoa8oU0bPH6/mG9Ppnqh+FMB+GmReAdTHgEn11VdL0c7Y9vI2MF K8nmJJqMSU2DoJdg2QHl3HPUfFEdWihIESwhE+a6vvM8zNl0Is9BA7yy82mTEVykUTcy NiYfWguOp44edVA5yYPLMdM4y3ttUbiL96ws8j9jYK06mNvOeiBSZeEu2c8Icj5nWkW3 cJ+OyPqKgE2nOCD7q5YpfKIBI/lf2B7GNMow0J5nJUu4CzdbfXwJLzQkUGlMZDZ66jL1 5Whw== 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 n19si1433929qtn.193.2017.05.11.16.07.04; Thu, 11 May 2017 16:07:05 -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 B9BFB60829; Thu, 11 May 2017 23:07:04 +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,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 BADC06069B; Thu, 11 May 2017 23:01:47 +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 E7F1360D4A; Thu, 11 May 2017 23:01:38 +0000 (UTC) Received: from forward5p.cmail.yandex.net (forward5p.cmail.yandex.net [77.88.31.20]) by lists.linaro.org (Postfix) with ESMTPS id C82E160694 for ; Thu, 11 May 2017 23:01:05 +0000 (UTC) Received: from smtp3h.mail.yandex.net (smtp3h.mail.yandex.net [IPv6:2a02:6b8:0:f05::117]) by forward5p.cmail.yandex.net (Yandex) with ESMTP id 9384F20C4F for ; Fri, 12 May 2017 02:01:03 +0300 (MSK) Received: from smtp3h.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp3h.mail.yandex.net (Yandex) with ESMTP id 4F013440EC9 for ; Fri, 12 May 2017 02:01:02 +0300 (MSK) Received: by smtp3h.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id orGMuV8N85-12YOl97n; Fri, 12 May 2017 02:01:02 +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 02:00:05 +0300 Message-Id: <1494543609-26126-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494543609-26126-1-git-send-email-odpbot@yandex.ru> References: <1494543609-26126-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 28 Subject: [lng-odp] [PATCH API-NEXT v4 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: b81277da57f0fe188a9a4e88872bba7ec92283ca **/ 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; }