From patchwork Mon Jan 24 10:34:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Moreno?= X-Patchwork-Id: 1583379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=cK++qVuY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jj5wg6RCyz9t0k for ; Mon, 24 Jan 2022 21:35:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9073983ED7; Mon, 24 Jan 2022 10:35:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z_T6qfUTKXCk; Mon, 24 Jan 2022 10:35:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0C70983F0B; Mon, 24 Jan 2022 10:35:26 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0C164C007E; Mon, 24 Jan 2022 10:35:26 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 20782C0072 for ; Mon, 24 Jan 2022 10:35:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 73B6483F05 for ; Mon, 24 Jan 2022 10:35:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SKQBX75dZL9P for ; Mon, 24 Jan 2022 10:35:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 6188183E59 for ; Mon, 24 Jan 2022 10:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643020520; 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=oH02652Sq/5DzO9bIplrxpjQHVqwsQ2v8y/yR6VSO54=; b=cK++qVuYD89XJt+XuouFDS2xxiQzHJkI4BsZNTbGngVAof229IZoclAwRbrv1ckdQnm0wZ DTrgOBrNycyJ2elhnHEwmPWiTWQwRJcDsu9K3i8UBtX+OCvxF/Y6xrhy2pSDACHY1RJcw0 upL3jJiKawoc7441bj0m3LJtnMGabQk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-396-hkqlbL8OPfqPuQwL3tFreQ-1; Mon, 24 Jan 2022 05:35:19 -0500 X-MC-Unique: hkqlbL8OPfqPuQwL3tFreQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D6CC1083F62; Mon, 24 Jan 2022 10:35:18 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.193.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AA327A2ED; Mon, 24 Jan 2022 10:35:16 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Mon, 24 Jan 2022 11:34:36 +0100 Message-Id: <20220124103445.2459400-5-amorenoz@redhat.com> In-Reply-To: <20220124103445.2459400-1-amorenoz@redhat.com> References: <20220124103445.2459400-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: jakub@redhat.com, fweimer@redhat.com, dceara@redhat.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH 04/13] list: ensure iterator is NULL after pop loop 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" After the loop ends, the iterator is not guaranteed to point to a valid object and should not be used. Make it NULL to avoid undefined behavior. Signed-off-by: Adrian Moreno --- include/openvswitch/list.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/openvswitch/list.h b/include/openvswitch/list.h index 263789b60..a63a51759 100644 --- a/include/openvswitch/list.h +++ b/include/openvswitch/list.h @@ -108,8 +108,9 @@ static inline bool ovs_list_is_short(const struct ovs_list *); UPDATE_MULTIVAR_SAFE(VAR)) #define LIST_FOR_EACH_POP(ITER, MEMBER, LIST) \ - while (!ovs_list_is_empty(LIST) \ - && (INIT_CONTAINER(ITER, ovs_list_pop_front(LIST), MEMBER), 1)) + while (!ovs_list_is_empty(LIST) ? \ + (INIT_CONTAINER(ITER, ovs_list_pop_front(LIST), MEMBER), 1) : \ + (ITER = NULL, 0)) /* Inline implementations. */