From patchwork Tue May 16 16:00:18 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: 99882 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp2101395qge; Tue, 16 May 2017 09:08:45 -0700 (PDT) X-Received: by 10.55.3.10 with SMTP id 10mr11852566qkd.65.1494950925197; Tue, 16 May 2017 09:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494950925; cv=none; d=google.com; s=arc-20160816; b=EWdQA72cSUu4UTdS4D8/UdkWgCdlhktsBavVHYyM30CE7wo3YgNo9tboRmJKCCIDVD U3uLan39kpA84ZhcrsdEJwltXpznOu4a38eEcRQ16RL/kNAH7H6lAXT0WJn7tClO837e XfG10y3ysW6vFSYWJSZsrRJydBHQE/8FZSb8xrVbx8L9ZM08g0AOa3s6ixCdMVHIWQRy F6XvWrEBhC2b5w3rzsP0+TMQpit+D2uxUmIMWqT15g9XMVT32QUcjWYVHuV3NPO2duIW V9XP5cY58o/hA5oV215hMDwamrA6QhnoHXaG4Q3xEvmswx0AP7aMdS88JavFnCzuludG 7UFg== 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=6odvAOEiH6+F07fkeSZ70Ct2ezgGe+3R7B+FF4Qc8p8=; b=Gf5wRmSCOMl1VE+bbgyJCguF9JBaZT8ozKszueIuFa2tcQanR7Cm1kJAKnsjPKiF7Q gijitlB7+gcKIY909OiujGtRIz+iUmcirFYclOzHJJtyKxbXUjFzSxXqFSJvjVeTUM8Y wAtSaWg8oDo90NfLP9W6x9QkSjVvzUtd3eBTVNMeVAVZK/WZJZ9ZHxbRw9e3S8y8i2TD IsdzZaTwXce0SzIw4bqkCClCCCH12OE+9juhUNXQ1vZaKlmHwmHMTyp5RqFIguwmnjPm 4vnL8zZgWl2JWYN8lP9JYajs4kDR5YoOfbLEvSEcOcevr3CUn+wIz+UAFY97Wff4ekt3 lN2g== 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 l88si13814079qki.138.2017.05.16.09.08.44; Tue, 16 May 2017 09:08:45 -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 D111760BDC; Tue, 16 May 2017 16:08:44 +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 5C1A560BF0; Tue, 16 May 2017 16:02:14 +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 56654608CD; Tue, 16 May 2017 16:01:36 +0000 (UTC) Received: from forward2o.cmail.yandex.net (forward2o.cmail.yandex.net [37.9.109.243]) by lists.linaro.org (Postfix) with ESMTPS id C104E607B3 for ; Tue, 16 May 2017 16:00:44 +0000 (UTC) Received: from smtp2h.mail.yandex.net (smtp2h.mail.yandex.net [IPv6:2a02:6b8:0:f05::116]) by forward2o.cmail.yandex.net (Yandex) with ESMTP id 647B72103F for ; Tue, 16 May 2017 19:00:43 +0300 (MSK) Received: from smtp2h.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2h.mail.yandex.net (Yandex) with ESMTP id 361B5780B18 for ; Tue, 16 May 2017 19:00:42 +0300 (MSK) Received: by smtp2h.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id uvbp18VO5L-0gjOFZ5i; Tue, 16 May 2017 19:00:42 +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: Tue, 16 May 2017 19:00:18 +0300 Message-Id: <1494950422-11135-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494950422-11135-1-git-send-email-odpbot@yandex.ru> References: <1494950422-11135-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 28 Subject: [lng-odp] [PATCH API-NEXT v5 7/11] 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: f4c213cccc49b4b28557506ad19fba49b872d24f ** Merge commit sha: e6ef5a70e5261ee32e5edb33fc7710d103010d95 **/ 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; }