From patchwork Wed Nov 6 19:01:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Traynor X-Patchwork-Id: 62602 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EFA6CA04AB; Wed, 6 Nov 2019 20:02:41 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C31441E881; Wed, 6 Nov 2019 20:02:32 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 58DF01E56D for ; Wed, 6 Nov 2019 20:02:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573066948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bsrCM0ug/pCjMiM0vDZz75VjM1S3KqQaLQml0riDCh0=; b=f14AWoo9XqdORenuTc9ctCkWGVKVwTA8kP4H0hK3u4Tp5I7eVJrq5UK6wM2+jpA9n6oByl J/V80pv91vmwzB5QptgYRqqGMB1fqKLXXSR0xXEqpbUZuUE7Az6eJFg64XSTyE+/z+bGJM YrEsdkVceBGpQeTe7uru9y1QIc5Uwm4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-214-s7PDk2WuNG2V6xLkxXtH0A-1; Wed, 06 Nov 2019 14:02:25 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ABB5E1005500; Wed, 6 Nov 2019 19:02:24 +0000 (UTC) Received: from rh.redhat.com (unknown [10.36.118.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A01B1001B35; Wed, 6 Nov 2019 19:02:23 +0000 (UTC) From: Kevin Traynor To: dev@dpdk.org Cc: david.marchand@redhat.com, Kevin Traynor , ndabilpuram@marvell.com, stable@dpdk.org Date: Wed, 6 Nov 2019 19:01:57 +0000 Message-Id: <20191106190203.10750-3-ktraynor@redhat.com> In-Reply-To: <20191106190203.10750-1-ktraynor@redhat.com> References: <20191001125315.6191-1-ktraynor@redhat.com> <20191106190203.10750-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: s7PDk2WuNG2V6xLkxXtH0A-1 X-Mimecast-Spam-Score: 0 Subject: [dpdk-dev] [v2 PATCH 2/8] common/cpt: fix possible NULL deference 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" 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: 6cc54096520d ("crypto/octeontx: add supported sessions") Cc: ndabilpuram@marvell.com Cc: stable@dpdk.org Signed-off-by: Kevin Traynor Reviewed-by: David Marchand --- There may be further rework needed to set it to the correct value, but for now at least prevent the NULL dereference. --- drivers/common/cpt/cpt_ucode.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h index 0dac12ee3..d5a0135d7 100644 --- a/drivers/common/cpt/cpt_ucode.h +++ b/drivers/common/cpt/cpt_ucode.h @@ -311,5 +311,6 @@ cpt_fc_ciph_set_key(void *ctx, cipher_type_t type, const uint8_t *key, 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: