From patchwork Tue Nov 5 11:09:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 2006818 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gBnlc9az; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjQb1254Nz1xxN for ; Tue, 5 Nov 2024 22:09:33 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 88EC840560; Tue, 5 Nov 2024 11:09:28 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 8aB9fQ2H1BLT; Tue, 5 Nov 2024 11:09:27 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5611A40566 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gBnlc9az Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 5611A40566; Tue, 5 Nov 2024 11:09:27 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 211D2C08A6; Tue, 5 Nov 2024 11:09:27 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3FE03C08A9 for ; Tue, 5 Nov 2024 11:09:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0F516408EA for ; Tue, 5 Nov 2024 11:09:20 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id P8kjwoi1K9-m for ; Tue, 5 Nov 2024 11:09:18 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amusil@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 2BAFB40913 Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 2BAFB40913 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gBnlc9az Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 2BAFB40913 for ; Tue, 5 Nov 2024 11:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730804956; 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=l5EapxQVnomW9MzAG228l8BsqfWdRT0Q+q4gLygDr/4=; b=gBnlc9aztP2lVQaLhdROrNScNn5qUA55Pda/K/fI8x7/58bSCvbi454r3g7mGTugmIqQ79 08lDbR2IqUXT0TaclZpe9oZrdAc00Q5WVC3ISffPvYuHPg6HqAVkZFdjMy8iMc9+6fFyyq BdxBWhE0WCqXDInj99jYReOQYhej7yI= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-622-WRgS--KbOcKGNk4bS-QbAw-1; Tue, 05 Nov 2024 06:09:15 -0500 X-MC-Unique: WRgS--KbOcKGNk4bS-QbAw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D2F231955F3C for ; Tue, 5 Nov 2024 11:09:14 +0000 (UTC) Received: from amusil.brq.redhat.com (unknown [10.43.17.32]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E20F21956086; Tue, 5 Nov 2024 11:09:13 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Tue, 5 Nov 2024 12:09:10 +0100 Message-ID: <20241105110911.280756-2-amusil@redhat.com> In-Reply-To: <20241105110911.280756-1-amusil@redhat.com> References: <20241105110911.280756-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 1/2] mirror: Adjust pointer checks reported by coverity. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" As pointed out by coverity, the code was structured in a way that m->sb_mirror might have been NULL. At that point in the code it's not possible. Add assert to emphasize that and remove redundant check for m->ovs_mirror. Signed-off-by: Ales Musil --- controller/mirror.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/controller/mirror.c b/controller/mirror.c index ebe455968..b557b96da 100644 --- a/controller/mirror.c +++ b/controller/mirror.c @@ -352,7 +352,8 @@ sync_ovn_mirror(struct ovn_mirror *m, struct ovsdb_idl_txn *ovs_idl_txn, return; } - if (m->sb_mirror && !m->ovs_mirror) { + ovs_assert(m->sb_mirror); + if (!m->ovs_mirror) { create_ovs_mirror(m, ovs_idl_txn, br_int, ovs_mirror_ports); if (!m->ovs_mirror) { return; @@ -390,7 +391,7 @@ should_delete_ovs_mirror(struct ovn_mirror *m) return false; } - if (m->ovs_mirror && !m->sb_mirror) { + if (!m->sb_mirror) { return true; }