Skip to content

Commit

Permalink
common/cpt: fix possible null dereference
Browse files Browse the repository at this point in the history
Coverity complains that ctrl_flags is set to NULL at the start
of the function and it may not have been set before there is a
jump to fc_success and it is dereferenced.

Check for NULL before dereference.

312fc_success:
   CID 344983 (#1 of 1): Explicit null dereferenced
   (FORWARD_NULL)7. var_deref_op: Dereferencing null pointer ctrl_flags.
313        *ctrl_flags = rte_cpu_to_be_64(*ctrl_flags);

Coverity issue: 344983
Fixes: 6cc5409 ("crypto/octeontx: add supported sessions")
Cc: stable@dpdk.org

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
  • Loading branch information
kevintraynor authored and tmonjalo committed Nov 8, 2019
1 parent e8b081e commit 01c6500
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/common/cpt/cpt_ucode.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ cpt_fc_ciph_set_key(void *ctx, cipher_type_t type, const uint8_t *key,
memcpy(fctx->enc.encr_key, key, key_len);

fc_success:
*ctrl_flags = rte_cpu_to_be_64(*ctrl_flags);
if (ctrl_flags != NULL)
*ctrl_flags = rte_cpu_to_be_64(*ctrl_flags);

success:
cpt_ctx->enc_cipher = type;
Expand Down

0 comments on commit 01c6500

Please sign in to comment.