From: Sunil Kumar Kori Date: Thu, 5 Apr 2018 08:35:48 +0000 (+0530) Subject: crypto/dpaa_sec: improve the error checking X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=22788c2c6a23d9c6bd6b9766065f0f3c2d203fb1;p=dpdk.git crypto/dpaa_sec: improve the error checking Reported by NXP's internal coverity Fixes: c3e85bdcc6e6 ("crypto/dpaa_sec: add crypto driver for NXP DPAA platform") Cc: stable@dpdk.org Signed-off-by: Sunil Kumar Kori Acked-by: Akhil Goyal --- diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 29af78145c..2dac510494 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -370,7 +370,7 @@ static int dpaa_sec_prep_cdb(dpaa_sec_session *ses) { struct alginfo alginfo_c = {0}, alginfo_a = {0}, alginfo = {0}; - uint32_t shared_desc_len = 0; + int32_t shared_desc_len = 0; struct sec_cdb *cdb = &ses->cdb; int err; #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN @@ -512,6 +512,12 @@ dpaa_sec_prep_cdb(dpaa_sec_session *ses) ses->digest_length, ses->dir); } } + + if (shared_desc_len < 0) { + PMD_TX_LOG(ERR, "error in preparing command block\n"); + return shared_desc_len; + } + cdb->sh_hdr.hi.field.idlen = shared_desc_len; cdb->sh_hdr.hi.word = rte_cpu_to_be_32(cdb->sh_hdr.hi.word); cdb->sh_hdr.lo.word = rte_cpu_to_be_32(cdb->sh_hdr.lo.word);