From patchwork Wed Feb 16 10:43:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1593624 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=bvA/mYXp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4JzF7h3ZGQz9sDX for ; Wed, 16 Feb 2022 21:49:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V9/U+liEA/cVlRfzBZ3QVfdDgOexezlBUq6zie5bODg=; b=bvA/mYXptEWK22 4Gd0VtpXRRfOeRyehbIKKrQYrW8ZmL6nhyk6KDIgeBBLIjiELwur1RK8HWQwHNWHEbr4Qnt6CTzId YMKqgQCIIG6yBtPT1aBA+4+qRExiDFn7GfDAnmb29i7KlBG0b9oj/VKM641XAU0zV+EF1F4Bcp0f/ Cav19jSUmZjb/UrjUF6BrdrJ7p1OI42bBFNKa1MiiGEPTq60cmpHePnYwhiaxWG5ZsaVakMt6vnAW WVNRA1OoUHPh6aIELZRysh6ARsr5PdUMm2WxPFW9ynZCgM8HU6cIp5Su1oF1+POda0589jAOWhKtT ql/suKqaY22DZVQY18zw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKHnb-006bWM-9V; Wed, 16 Feb 2022 10:44:39 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKHms-006bJe-7C for openwrt-devel@lists.openwrt.org; Wed, 16 Feb 2022 10:43:57 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 10F233D08; Wed, 16 Feb 2022 11:43:49 +0100 (CET) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 8b31a62c; Wed, 16 Feb 2022 11:43:24 +0100 (CET) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: Felix Fietkau Subject: [PATCH 19.07 ubus 1/3] libubus: use list_empty/list_first_entry in ubus_process_pending_msg Date: Wed, 16 Feb 2022 11:43:36 +0100 Message-Id: <20220216104338.15704-2-ynezz@true.cz> In-Reply-To: <20220216104338.15704-1-ynezz@true.cz> References: <20220216104338.15704-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220216_024354_484443_30E654A6 X-CRM114-Status: UNSURE ( 7.97 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Felix Fietkau Simplifies checks and avoids potential list corruption on recursive calls Signed-off-by: Felix Fietkau (cherry picked from commit 2099bb3ad9972c6188c38fd885ae74f3323fcacc) --- libubus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Felix Fietkau Simplifies checks and avoids potential list corruption on recursive calls Signed-off-by: Felix Fietkau (cherry picked from commit 2099bb3ad9972c6188c38fd885ae74f3323fcacc) --- libubus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libubus.c b/libubus.c index 91f317c59867..7ce454eabc64 100644 --- a/libubus.c +++ b/libubus.c @@ -115,12 +115,13 @@ ubus_process_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd) static void ubus_process_pending_msg(struct uloop_timeout *timeout) { struct ubus_context *ctx = container_of(timeout, struct ubus_context, pending_timer); - struct ubus_pending_msg *pending, *tmp; + struct ubus_pending_msg *pending; - list_for_each_entry_safe(pending, tmp, &ctx->pending, list) { + while (!list_empty(&ctx->pending)) { if (ctx->stack_depth) break; + pending = list_first_entry(&ctx->pending, struct ubus_pending_msg, list); list_del(&pending->list); ubus_process_msg(ctx, &pending->hdr, -1); free(pending);