From patchwork Mon Aug 7 14: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: 109552 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1641723qge; Mon, 7 Aug 2017 07:01:43 -0700 (PDT) X-Received: by 10.55.215.28 with SMTP id m28mr872453qki.318.1502114503750; Mon, 07 Aug 2017 07:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502114503; cv=none; d=google.com; s=arc-20160816; b=xYZptutIsCFIhIKONa4s5YcxZ65RVlI27uybEImE/dmhFyixQIxObAXGFUumxIQZd/ +aFvrz7IWzn7atlz3UxD/xl4VqxorUCnbVyKK22sykvikPhwiK0NImJnOeaZSvVhXmR1 cUvDBRe6SwI08Zy1qQW4TzFSofdeA10jnMuEfQL6+5tFEcPlLENS97dxzYkU7XUuit3Z gLOc2Hm/1LwY8iV++TY1d0pishw9orjRZZmC6wiYGKURYcAQ433nBi5Ypbx724zG8O31 v5vwrIp/nj8TcCaeL/7Rxt+HVkhth/Z1zJhEjlO5xioAqOFWRRUuuUbATN8WcsWS+uhq S9Vg== 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=+w2GkrXdGfGmOqOvmFGsO8+oh5Nn7U1Rzlm58oqa4lo=; b=L+s9Isp244pANX2TnG5MaURBPo4jwa0UqJl71v6M/Mjaz49FTa5Our+8y1Dz3iw53K VUMESzEYgFKpNuKXdvDuLJ1cq4+A7qI5VNPwhXIgWXg8glVm2kJholjMjZb6il1Y5gjy VHSALgRStDNKdichh+VA2a8Q94UhSrKAnuOAKk6OBBNfkXiDUd7TXM2WhZfN2gijOHPy bHz4ZfGFwtDsdKMAc70K1OMsJ5axFFAUeS/nV/KxuDsvhFdTaGkDfqO2f0dn3dKbvn5s lVMKYO5Zv/SDLacK1UCa3kiPMZSAPqpG0Z2o+k97CyQ1jWJbOiKSpIJy5aPO484ML4PN oYsA== 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 j8si7100631qtb.37.2017.08.07.07.01.43; Mon, 07 Aug 2017 07:01:43 -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 3E87B60C2D; Mon, 7 Aug 2017 14:01:43 +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 1359360DB8; Mon, 7 Aug 2017 14:00:42 +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 8C52960D85; Mon, 7 Aug 2017 14:00:29 +0000 (UTC) Received: from forward18o.cmail.yandex.net (forward18o.cmail.yandex.net [37.9.109.216]) by lists.linaro.org (Postfix) with ESMTPS id 4C75160D3A for ; Mon, 7 Aug 2017 14:00:24 +0000 (UTC) Received: from mxback19j.mail.yandex.net (mxback19j.mail.yandex.net [IPv6:2a02:6b8:0:1619::95]) by forward18o.cmail.yandex.net (Yandex) with ESMTP id D54D6228FF for ; Mon, 7 Aug 2017 17:00:22 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback19j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 0d8xnZn03Q-0Mnu5dig; Mon, 07 Aug 2017 17:00:22 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id jYzLwXN8Yl-0LwGnLr9; Mon, 07 Aug 2017 17:00:22 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 7 Aug 2017 17:00:09 +0300 Message-Id: <1502114410-25867-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502114410-25867-1-git-send-email-odpbot@yandex.ru> References: <1502114410-25867-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 95 Subject: [lng-odp] [PATCH API-NEXT v2 1/2] api: crypto: clarify for odp_crypto_session_create 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 Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 95 (lumag:crypto-session-create) ** https://github.com/Linaro/odp/pull/95 ** Patch: https://github.com/Linaro/odp/pull/95.patch ** Base sha: 2394317ab247fa14b4e239aec512afee7eac4524 ** Merge commit sha: bc2a40cc94ced5ba8ec7b86fbdef99958ed37009 **/ include/odp/api/spec/crypto.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index 6d4807c4..715ba9a5 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -647,11 +647,12 @@ int odp_crypto_auth_capability(odp_auth_alg_t auth, * * Create a crypto session according to the session parameters. Use * odp_crypto_session_param_init() to initialize parameters into their - * default values. + * default values. If call ends up with an error no new session will be + * created. * - * @param param Session parameters - * @param session Created session else ODP_CRYPTO_SESSION_INVALID - * @param status Failure code if unsuccessful + * @param param Session parameters + * @param[out] session Created session else ODP_CRYPTO_SESSION_INVALID + * @param[out] status Failure code if unsuccessful * * @retval 0 on success * @retval <0 on failure From patchwork Mon Aug 7 14:00:10 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: 109553 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1643134qge; Mon, 7 Aug 2017 07:02:42 -0700 (PDT) X-Received: by 10.200.52.6 with SMTP id u6mr909128qtb.26.1502114562265; Mon, 07 Aug 2017 07:02:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502114562; cv=none; d=google.com; s=arc-20160816; b=coTvGPyDO3vre2PrQfFy/gfhGhlXdoXseyrrkm8YiLL12IaM1/k50/MUjEkswJL0oG DQBGf1PkA6ZdJjwLkvx1xQHElVHYKl3ReV0q7520g5GNpDEucpkWFgOQdmyxijaTypvd DEH+nJ/faqy8oaLqYtuy1ivXxNC1Q/GhclPLMSR80I6VGqrQqcy6N28sWhhqKUnJqOkm IEMOeXtPT+XI17+Z5J8dUZ+o8e3R2Tp83x00KFpodCrL+ZfK3R1oHS3XHuNuh5+RmaQg G7DmoGAgfw06o0tmORLLeW6UJ+ClbPREK3uxvxQlIqD12mF5Mj2GFXBtemaM5QwErSN9 BsNg== 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=3F0ywjhrc84cyVJ6b5Gz4iRymDiz0+Op8halGsREzj8=; b=FxVb2rkbs1xl+j9cD11fCvi9UcZOk5Px3oNWI1XtNdPG6XAmEcGqYzXWfZjGyDsBzS c82u6b3RzuEJsHjDEFl4W6PB9n0MgvN6iLT2SFjvl53kfZtWYezKBFMrVko6cVKZbZL6 35w16Nr77p0wO2tK8aq4YEWA6Sg/I1Bczl5Cmy5NvEFoJp/xTB6M5P4wJ2Xn60T78rVE 2/1JAOadogqMZfezVTjlRVePqVitNLqtETc+2b7aBpINPRSZcJZg7xlSMpPRX2jnWd17 X7BMGiSMWt/d/OUU5IdTS0St5VBqpKZA6VP4fyeSC9ImEvWEeYNn3OYx5ZDC+rvSKl7G tnEQ== 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 l190si7342363qkd.299.2017.08.07.07.02.41; Mon, 07 Aug 2017 07:02:42 -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 D141F61E03; Mon, 7 Aug 2017 14:02:41 +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 848C26063C; Mon, 7 Aug 2017 14:00:46 +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 D549E60E16; Mon, 7 Aug 2017 14:00:36 +0000 (UTC) Received: from forward9o.cmail.yandex.net (forward9o.cmail.yandex.net [37.9.109.56]) by lists.linaro.org (Postfix) with ESMTPS id 8AF7760C2D for ; Mon, 7 Aug 2017 14:00:31 +0000 (UTC) Received: from mxback4g.mail.yandex.net (mxback4g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:165]) by forward9o.cmail.yandex.net (Yandex) with ESMTP id 886B822EDA for ; Mon, 7 Aug 2017 17:00:23 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback4g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Bs1aFfVIjF-0NbKe7C5; Mon, 07 Aug 2017 17:00:23 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id jYzLwXN8Yl-0Mweor4g; Mon, 07 Aug 2017 17:00:22 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 7 Aug 2017 17:00:10 +0300 Message-Id: <1502114410-25867-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502114410-25867-1-git-send-email-odpbot@yandex.ru> References: <1502114410-25867-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 95 Subject: [lng-odp] [PATCH API-NEXT v2 2/2] linux-gen: crypto: unify odp_crypto_session_create error path 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 Make sure that or error session is always returned as ODP_CRYPTO_SESSION_INVALID. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 95 (lumag:crypto-session-create) ** https://github.com/Linaro/odp/pull/95 ** Patch: https://github.com/Linaro/odp/pull/95.patch ** Base sha: 2394317ab247fa14b4e239aec512afee7eac4524 ** Merge commit sha: bc2a40cc94ced5ba8ec7b86fbdef99958ed37009 **/ platform/linux-generic/odp_crypto.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index ca51bdf0..1f49261a 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -697,14 +697,11 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, odp_crypto_generic_session_t *session; int aes_gcm = 0; - /* Default to successful result */ - *status = ODP_CRYPTO_SES_CREATE_ERR_NONE; - /* Allocate memory for this session */ session = alloc_session(); if (NULL == session) { *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM; - return -1; + goto err; } /* Copy parameters */ @@ -712,8 +709,8 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, if (session->p.iv.length > MAX_IV_LEN) { ODP_DBG("Maximum IV length exceeded\n"); - free_session(session); - return -1; + *status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER; + goto err; } /* Copy IV data */ @@ -764,8 +761,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; + goto err; } aes_gcm = 0; @@ -825,13 +821,20 @@ 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; + goto err; } /* We're happy */ *session_out = (intptr_t)session; + *status = ODP_CRYPTO_SES_CREATE_ERR_NONE; return 0; + +err: + /* error status should be set at this moment */ + if (session != NULL) + free_session(session); + *session_out = ODP_CRYPTO_SESSION_INVALID; + return -1; } int odp_crypto_session_destroy(odp_crypto_session_t session)