From patchwork Thu May 11 21:00:09 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: 99675 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp926320qge; Thu, 11 May 2017 14:07:23 -0700 (PDT) X-Received: by 10.55.39.148 with SMTP id n142mr509667qkn.223.1494536843329; Thu, 11 May 2017 14:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494536843; cv=none; d=google.com; s=arc-20160816; b=SRzDELg8uA6eOufduDROq488IundH8MfKIXlsoZn/K+EbZmLfbRzxHk1Wbyx66UeL5 6qP3E0WZWzXSVAigsciM41HgizgkCXQYtFnVePZmENviiHYEfc5d+jbOVo7xp4oz+zoW ZkVfRJyszKi2W/bNJnKcdtdj5nARKL4XCLaNQGEe8j31fa1y2YKIKmd6cAnOY+o7DbzG uECE1ND6NBbppom63e80AjKwqVe9oYMKq1GkuZjCIzvX6Ajdw0VTomsmf5sOBoSGmGX4 9WeJauCoiaXNXXxNM6b+Lu0TFXiCu7z4M42DzTmBte/f7LUf4Cp6SR6ikefjHaQ+dfta 62HA== 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=WBw7zbL1Ai4cw3bJbbYKT47WloyWTGaBaa97zFATeR8=; b=DCXjkKv5paQydVrJM1t49Vzr7vRPC9WLszXyB5zATGb8vA4x/cKNpsapG8Ovm2glO/ +aZPM1Fs2m+BvNg7A6XtcIsIU2v8Q1TeIU9ZOlAM1qFSbjG8AgNkRo16cTjhrrBWdsie AMzZXIlBKB/44gQmjNbz12X4NZjVcwrpib9rGKLzeX16dpmctPvQtPeMNpR24WGdsrmF GqR3tmpJuIA4E045r/uV2FW4gN80dQzY8OeT4x0WV5UBZj4vDKn2qn7in9eQU6dmNrWR fZu+23XTb3HeHSE4mslRVFZr7CLQ4YwbU8dzyWTfqWC2j+IJeCRk/Hv5yInYEqhKEPqJ 5iUQ== 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 94si1216954qkw.248.2017.05.11.14.07.23; Thu, 11 May 2017 14:07:23 -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 0612060CE2; Thu, 11 May 2017 21:07:23 +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 6BDC760D3D; Thu, 11 May 2017 21:03:26 +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 A08F060CE5; Thu, 11 May 2017 21:03:20 +0000 (UTC) Received: from forward5h.cmail.yandex.net (forward5h.cmail.yandex.net [87.250.230.20]) by lists.linaro.org (Postfix) with ESMTPS id 52D9760CE5 for ; Thu, 11 May 2017 21:01:15 +0000 (UTC) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [37.140.190.28]) by forward5h.cmail.yandex.net (Yandex) with ESMTP id E414B20D9D for ; Fri, 12 May 2017 00:01:13 +0300 (MSK) Received: from smtp3o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp3o.mail.yandex.net (Yandex) with ESMTP id B84B22940D19 for ; Fri, 12 May 2017 00:01:13 +0300 (MSK) Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id P1VpeccWIw-1C5KNtm0; Fri, 12 May 2017 00:01:12 +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 00:00:09 +0300 Message-Id: <1494536413-25411-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494536413-25411-1-git-send-email-odpbot@yandex.ru> References: <1494536413-25411-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 28 Subject: [lng-odp] [PATCH API-NEXT v1 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: 56945703e4054023470e63b004391db311215076 **/ 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; }