From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id DCD665A0271; Thu, 22 Jan 2026 15:13:19 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] tcp: Add error checking for flow_epoll_set() in tcp_flow_migrate_target() Date: Thu, 22 Jan 2026 15:13:19 +0100 Message-ID: <20260122141319.3054301-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: W5XQ6WX2QEO4FW62LQEPJKJVE3GSQFVC X-Message-ID-Hash: W5XQ6WX2QEO4FW62LQEPJKJVE3GSQFVC X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier , David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Commit 90287c2a774e ("tcp: Register fds with epoll at flow creation") added a call to flow_epoll_set() in tcp_flow_migrate_target() without checking for the error code. As Laurent explains, that's harmless, as tcp_flow_migrate_target_ext() will clean up the flow anyway, and we'll just uselessly call flow_hash_insert() before removing it again. But Coverity Scan complains about the unchecked return code, so check it, skip flow_hash_insert() in that case, and explain in comments why we don't have to do anything else. Signed-off-by: Stefano Brivio --- tcp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tcp.c b/tcp.c index 6a26826..0a6b7ff 100644 --- a/tcp.c +++ b/tcp.c @@ -3684,17 +3684,19 @@ int tcp_flow_migrate_target(struct ctx *c, int fd) if ((rc = tcp_flow_repair_socket(c, conn))) { flow_err(flow, "Can't set up socket: %s, drop", strerror_(-rc)); - /* Can't leave the flow in an incomplete state */ - FLOW_ACTIVATE(conn); - return 0; + goto out; } flow_epollid_set(&conn->f, EPOLLFD_ID_DEFAULT); - flow_epoll_set(&conn->f, EPOLL_CTL_ADD, 0, conn->sock, !TAPSIDE(conn)); + if (flow_epoll_set(&conn->f, EPOLL_CTL_ADD, 0, conn->sock, + !TAPSIDE(conn))) + goto out; /* tcp_flow_migrate_target_ext() will clean this up */ flow_hash_insert(c, TAP_SIDX(conn)); - FLOW_ACTIVATE(conn); +out: + /* Never leave the flow in an incomplete state */ + FLOW_ACTIVATE(conn); return 0; } -- 2.43.0