From: Declan Doherty Date: Mon, 15 Feb 2016 17:06:07 +0000 (+0000) Subject: aesni_mb: fix strict-aliasing compilation rule X-Git-Tag: spdx-start~7592 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=591f0e8bb04176aed1a3894d8605b0eb1e66a025;p=dpdk.git aesni_mb: fix strict-aliasing compilation rule When compiling the AESNI_MB PMD with GCC 4.4.7 on Centos 6.7 a "dereferencing pointer ‘obj_p’ does break strict-aliasing rules" warning occurs in the get_session() function. Fixes: 924e84f87306 ("aesni_mb: add driver for multi buffer based crypto") Signed-off-by: Declan Doherty Acked-by: Pablo de Lara --- diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c index a655ed88a1..c7d884c22b 100644 --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c @@ -298,7 +298,7 @@ aesni_mb_set_session_parameters(const struct aesni_mb_ops *mb_ops, static struct aesni_mb_session * get_session(struct aesni_mb_qp *qp, struct rte_crypto_op *crypto_op) { - struct aesni_mb_session *sess; + struct aesni_mb_session *sess = NULL; if (crypto_op->type == RTE_CRYPTO_OP_WITH_SESSION) { if (unlikely(crypto_op->session->type != @@ -307,16 +307,19 @@ get_session(struct aesni_mb_qp *qp, struct rte_crypto_op *crypto_op) sess = (struct aesni_mb_session *)crypto_op->session->_private; } else { - struct rte_cryptodev_session *c_sess = NULL; + void *_sess = NULL; - if (rte_mempool_get(qp->sess_mp, (void **)&c_sess)) + if (rte_mempool_get(qp->sess_mp, (void **)&_sess)) return NULL; - sess = (struct aesni_mb_session *)c_sess->_private; + sess = (struct aesni_mb_session *) + ((struct rte_cryptodev_session *)_sess)->_private; if (unlikely(aesni_mb_set_session_parameters(qp->ops, - sess, crypto_op->xform) != 0)) - return NULL; + sess, crypto_op->xform) != 0)) { + rte_mempool_put(qp->sess_mp, _sess); + sess = NULL; + } } return sess;