From patchwork Wed May 10 00: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: 98958 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp2076269qge; Tue, 9 May 2017 17:01:32 -0700 (PDT) X-Received: by 10.36.111.205 with SMTP id x196mr3046823itb.117.1494374492802; Tue, 09 May 2017 17:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494374492; cv=none; d=google.com; s=arc-20160816; b=C0OdF3eTtV3zTazER0xqe6xwpalaqpN7JiZbA7xzHjwcK2/VjDHmAShZfpITpft8ez C6YZ2G3j+pwijNvIoNUgR11KzRzEi/3K6ICRqN0FUn88eZ5HIyBjYZRaZxYyNYDVaatQ xBtyNm/yEIeh8eppwLI6GxPSQaeWo1WE6x+ux+KE/IKPWhItyK//zsKseLLUwPNoAzyI Ww+pwZEmAnf4w2LhyCBOzZ51W5QatqzDqARzeJvcqHiINTwRSHSsTTdvmZDQ6sDIgDB2 NorN9y2rxG7366nxYAnjmDRwWRE4fF2m29sHosxC9zfg+H1BWHKfuSBcqZg7qIvc10s8 lGBg== 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=HXR/LkK9Z26YgU3F2uTRa5qeALYXzG96ZF67Iele+RI=; b=qRBUeAem+WIWrZ4a1z9cERCdKhkxOanCZnYNLmZR3q2O/HZ1e1tVuiMbd72caRB2vm yCNJvZJ6Idye6IkZSBEQJpO9jN0UwICZMy8mjWkrflgvHaBczHXMGdaItGcA32jsBM+K NjCGNilcVNpXu97AgViAgyrXloRJZFfbbQ97g7W6hrYuary7RlAdGJGyXi9XFWhXTDrj LdbxDGuYlbQxNP7XPz/T1QNKwlzNTQMHkaKa8kYrwNHGp0liu5ryFrrjl9Ka7AEMaXoZ HiB0LBRX8NwYMQsnzzpJG4sSdES94nLqqUdTDSnil/8FIo7vNx1jbdw5Kf27am6AyhQ2 fVpA== 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 4si538582ioy.249.2017.05.09.17.01.32; Tue, 09 May 2017 17:01:32 -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 578BD60C1C; Wed, 10 May 2017 00:01:32 +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 197FC6085E; Wed, 10 May 2017 00:01:06 +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 ED4D960854; Wed, 10 May 2017 00:00:47 +0000 (UTC) Received: from forward1j.cmail.yandex.net (forward1j.cmail.yandex.net [5.255.227.19]) by lists.linaro.org (Postfix) with ESMTPS id 0C88A6084B for ; Wed, 10 May 2017 00:00:46 +0000 (UTC) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [37.140.190.27]) by forward1j.cmail.yandex.net (Yandex) with ESMTP id 7785D203AB for ; Wed, 10 May 2017 03:00:44 +0300 (MSK) Received: from smtp2o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2o.mail.yandex.net (Yandex) with ESMTP id 453F75080E2F for ; Wed, 10 May 2017 03:00:43 +0300 (MSK) Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ibbOnpZ7bV-0gxqLTIU; Wed, 10 May 2017 03: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: Wed, 10 May 2017 03:00:05 +0300 Message-Id: <1494374405-10131-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494374405-10131-1-git-send-email-odpbot@yandex.ru> References: <1494374405-10131-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 25 Subject: [lng-odp] [PATCH v1 1/1] 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 25 (lumag:crypto-fix-create) ** https://github.com/Linaro/odp/pull/25 ** Patch: https://github.com/Linaro/odp/pull/25.patch ** Base sha: 79ba737a404d2833ad33d8f84ed6ce82c9a8c18e ** Merge commit sha: 428c9ea1c0e80039547f12fa2a36bccd4c29be19 **/ 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 b432f84..c5473d9 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -678,6 +678,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; } @@ -724,6 +725,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; } @@ -763,6 +765,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; }