From patchwork Wed Apr 5 19:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1765721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PsFY32hrRz1yZT for ; Thu, 6 Apr 2023 05:48:07 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id DE5234177A; Wed, 5 Apr 2023 19:48:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org DE5234177A X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YQ1B8veXGG9x; Wed, 5 Apr 2023 19:48:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 8CCAA409E7; Wed, 5 Apr 2023 19:48:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8CCAA409E7 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BF64EC007A; Wed, 5 Apr 2023 19:48:01 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 60982C0090 for ; Wed, 5 Apr 2023 19:48:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 210C240132 for ; Wed, 5 Apr 2023 19:48:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 210C240132 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id varlWcmN8ChV for ; Wed, 5 Apr 2023 19:47:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5220540912 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5220540912 for ; Wed, 5 Apr 2023 19:47:59 +0000 (UTC) Received: (Authenticated sender: i.maximets@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id E205D40004; Wed, 5 Apr 2023 19:47:56 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Wed, 5 Apr 2023 21:48:13 +0200 Message-Id: <20230405194813.548329-3-i.maximets@ovn.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230405194813.548329-1-i.maximets@ovn.org> References: <20230405194813.548329-1-i.maximets@ovn.org> MIME-Version: 1.0 Cc: Dumitru Ceara , Ilya Maximets Subject: [ovs-dev] [PATCH ovn v4 2/2] expr: Avoid crash if all sub-expressions crushed down to 'true'. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" expr_sort() can potentially return NULL if all sub-expressions got crushed into 'true'. This didn't happen before, but can happen with more aggressive optimizations in crush_or(). Acked-by: Han Zhou Signed-off-by: Ilya Maximets --- lib/expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/expr.c b/lib/expr.c index 0cf54d486..9659b9b63 100644 --- a/lib/expr.c +++ b/lib/expr.c @@ -3003,7 +3003,7 @@ expr_sort(struct expr *expr) } free(subs); - return expr; + return expr ? expr : expr_create_boolean(true); } static struct expr *expr_normalize_or(struct expr *expr);