From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23D4DA0487 for ; Fri, 5 Jul 2019 15:28:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9522D1BECE; Fri, 5 Jul 2019 15:28:17 +0200 (CEST) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40081.outbound.protection.outlook.com [40.107.4.81]) by dpdk.org (Postfix) with ESMTP id C80A41BEB2 for ; Fri, 5 Jul 2019 15:28:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7WGhoTnuyt9ul9zwDZsBaNMljjouQY44u/AAUjQilCg=; b=mB1TqmfYz6eXagdV1i+uRqrZaw3BJWQSqdGCT9cW0dIsSJPf+bbPsH9irDFMAeFb3f4NI4V62bGKTsGXoDnhhYLzOM9SOpCQk9UCoyLI4qGAOSbyBGkXf0WuCxMBxmS+ufRvWcBH/I8drdMrdpaSn70p9CP6XyRA7QWKMKh/N+k= Received: from VE1PR04MB6639.eurprd04.prod.outlook.com (20.179.235.82) by VE1PR04MB6702.eurprd04.prod.outlook.com (20.179.235.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18; Fri, 5 Jul 2019 13:28:15 +0000 Received: from VE1PR04MB6639.eurprd04.prod.outlook.com ([fe80::a929:3d03:7bb7:d5e0]) by VE1PR04MB6639.eurprd04.prod.outlook.com ([fe80::a929:3d03:7bb7:d5e0%7]) with mapi id 15.20.2052.010; Fri, 5 Jul 2019 13:28:15 +0000 From: Akhil Goyal To: Fan Zhang , "dev@dpdk.org" Thread-Topic: [PATCH] crypto/mvsam: fix missed code change for mvsam Thread-Index: AQHVMzTmuqaz8H3LFEiX8ZaVHS6sdaa8BBMQ Date: Fri, 5 Jul 2019 13:28:15 +0000 Message-ID: References: <20190705132349.7245-1-roy.fan.zhang@intel.com> In-Reply-To: <20190705132349.7245-1-roy.fan.zhang@intel.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=akhil.goyal@nxp.com; x-originating-ip: [92.120.1.65] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 703a9b3f-4520-4b13-a33f-08d7014ca2c5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VE1PR04MB6702; x-ms-traffictypediagnostic: VE1PR04MB6702: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3826; x-forefront-prvs: 008960E8EC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(396003)(39860400002)(346002)(366004)(376002)(189003)(199004)(7696005)(6506007)(68736007)(478600001)(71200400001)(316002)(99286004)(33656002)(110136005)(55016002)(2501003)(76176011)(446003)(102836004)(9686003)(476003)(71190400001)(74316002)(6246003)(305945005)(66066001)(186003)(7736002)(44832011)(53936002)(486006)(11346002)(5660300002)(26005)(66946007)(76116006)(3846002)(64756008)(14454004)(6116002)(73956011)(86362001)(66476007)(66556008)(66446008)(81156014)(229853002)(8676002)(256004)(25786009)(6436002)(2906002)(8936002)(81166006)(52536014); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6702; H:VE1PR04MB6639.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: rhPhsgN8NDtHd6fLt6q7lX3X7i3YUJ2nKz++mHAMlfoDGcP+RBJHS+wN2fsVWSPZhSMgBNlneVjOciZ2SQdfcVzpgsalV3RC6g6HC5wMFCEVO3M3ipvh3rGiblfS6Dnw5iPolByQEWluAuMxH1ghRnJBhD3BgM9upNQsn2CEdKJQnV4z30JknzwNmjwP8qGf0vBg5czPboxLMJN8PGB7YMeLAfyqL3PA0EuY9D+8HayCWoR1x0FRb/QSJDfagCOaz3/rXnB79Y2PjHUZ+MOA4Df2KG/1s6E0fiAw372jhkT90eCwOFc9xDFsFwiO9IhiQidjOiZBA8ojlfy4clgA0K1/rFYtqj1Pz8aZVcS2Hkxzw6y5BD0+pfGCBb+VaReMc20XFegn7w6W/jCUrd2bSl8XlKnj3bAndeIrrkh8Zaw= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 703a9b3f-4520-4b13-a33f-08d7014ca2c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jul 2019 13:28:15.5258 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: akhil.goyal@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6702 Subject: Re: [dpdk-dev] [PATCH] crypto/mvsam: fix missed code change for mvsam X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Fan, >=20 > This patch fixes the missed "uint8_t *" to "const uint8_t *" xform > key data type change for mvsam driver. >=20 > Fixes: f3390532cf6a ("cryptodev: make xform key pointer constant") >=20 > Signed-off-by: Fan Zhang > --- > drivers/crypto/mvsam/rte_mrvl_pmd.c | 44 > ++++++++++++++++++++++++++++++--- > drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 9 +++++++ > 2 files changed, 49 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c > b/drivers/crypto/mvsam/rte_mrvl_pmd.c > index c2ae82a26..65e4769f2 100644 > --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c > +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c > @@ -222,6 +222,8 @@ static int > mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *se= ss, > const struct rte_crypto_sym_xform *cipher_xform) > { > + uint8_t *cipher_key; > + > /* Make sure we've got proper struct */ > if (cipher_xform->type !=3D RTE_CRYPTO_SYM_XFORM_CIPHER) { > MRVL_LOG(ERR, "Wrong xform struct provided!"); > @@ -256,8 +258,17 @@ mrvl_crypto_set_cipher_session_parameters(struct > mrvl_crypto_session *sess, > return -EINVAL; > } >=20 > + cipher_key =3D malloc(cipher_xform->cipher.key.length); > + if (cipher_key =3D=3D NULL) { > + MRVL_LOG(ERR, "Insufficient memory!"); > + return -ENOMEM; > + } > + > + memcpy(cipher_key, cipher_xform->cipher.key, > + cipher_xform->cipher.key.length); > + > sess->sam_sess_params.cipher_key_len =3D cipher_xform- > >cipher.key.length; > - sess->sam_sess_params.cipher_key =3D cipher_xform->cipher.key.data; > + sess->sam_sess_params.cipher_key =3D cipher_key; >=20 > return 0; > } > @@ -273,6 +284,8 @@ static int > mrvl_crypto_set_auth_session_parameters(struct mrvl_crypto_session *sess= , > const struct rte_crypto_sym_xform *auth_xform) > { > + uint8_t *auth_key =3D NULL; > + > /* Make sure we've got proper struct */ > if (auth_xform->type !=3D RTE_CRYPTO_SYM_XFORM_AUTH) { > MRVL_LOG(ERR, "Wrong xform struct provided!"); > @@ -293,9 +306,21 @@ mrvl_crypto_set_auth_session_parameters(struct > mrvl_crypto_session *sess, > auth_map[auth_xform->auth.algo].auth_alg; > sess->sam_sess_params.u.basic.auth_icv_len =3D > auth_xform->auth.digest_length; > + > + if (auth_xform->auth.key.length > 0) { > + auth_key =3D malloc(auth_xform->auth.key.length); > + if (auth_key =3D=3D NULL) { > + MRVL_LOG(ERR, "Not enough memory!"); > + return -EINVAL; > + } > + > + memcpy(auth_key, auth_xform->auth.key.data, > + auth_xform->auth.key.length); > + } > + > + Extra blank spaces. > /* auth_key must be NULL if auth algorithm does not use HMAC */ > - sess->sam_sess_params.auth_key =3D auth_xform->auth.key.length ? > - auth_xform->auth.key.data : NULL; > + sess->sam_sess_params.auth_key =3D auth_key; > sess->sam_sess_params.auth_key_len =3D auth_xform->auth.key.length; >=20 > return 0; > @@ -312,6 +337,8 @@ static int > mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess= , > const struct rte_crypto_sym_xform *aead_xform) > { > + uint8_t *aead_key; > + > /* Make sure we've got proper struct */ > if (aead_xform->type !=3D RTE_CRYPTO_SYM_XFORM_AEAD) { > MRVL_LOG(ERR, "Wrong xform struct provided!"); > @@ -344,7 +371,16 @@ mrvl_crypto_set_aead_session_parameters(struct > mrvl_crypto_session *sess, > return -EINVAL; > } >=20 > - sess->sam_sess_params.cipher_key =3D aead_xform->aead.key.data; > + aead_key =3D malloc(aead_xform->aead.key.length); > + if (aead_key =3D=3D NULL) { > + MRVL_LOG(ERR, "Insufficient memory!"); > + return -ENOMEM; > + } > + > + memcpy(aead_key, aead_xform->aead.key.data, > + aead_xform->aead.key.length); > + > + sess->sam_sess_params.cipher_key =3D aead_key; > sess->sam_sess_params.cipher_key_len =3D aead_xform- > >aead.key.length; >=20 > if (sess->sam_sess_params.cipher_mode =3D=3D SAM_CIPHER_GCM) > diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c > b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c > index f6bf2cd4c..b334c7694 100644 > --- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c > +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c > @@ -751,6 +751,8 @@ > mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev > *dev, > return -ENOMEM; > } >=20 > + memset(sess_private_data, 0, sizeof(struct mrvl_crypto_session)); > + > ret =3D mrvl_crypto_set_session_parameters(sess_private_data, xform); > if (ret !=3D 0) { > MRVL_LOG(ERR, "Failed to configure session parameters!"); > @@ -769,6 +771,13 @@ > mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev > *dev, > return -EIO; > } >=20 > + /* free the keys memory allocated for session creation */ > + if (mrvl_sess->sam_sess_params.cipher_key !=3D NULL) > + free(mrvl_sess->sam_sess_params.cipher_key); > + if (mrvl_sess->sam_sess_params.auth_key !=3D NULL) > + free(mrvl_sess->sam_sess_params.auth_key); > + > + Extra blank and missing the aead key free. > return 0; > } >=20 > -- > 2.14.5