From patchwork Mon Apr 20 16:57:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1273567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13b; helo=mail-lf1-x13b.google.com; envelope-from=swupdate+bncbcxploxj6ikrbhnj672akgqezckuuaa@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=CzcOGbOR; dkim-atps=neutral Received: from mail-lf1-x13b.google.com (mail-lf1-x13b.google.com [IPv6:2a00:1450:4864:20::13b]) (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 ozlabs.org (Postfix) with ESMTPS id 495XvR6v0tz9sSd for ; Tue, 21 Apr 2020 02:58:10 +1000 (AEST) Received: by mail-lf1-x13b.google.com with SMTP id d5sf4449159lfb.5 for ; Mon, 20 Apr 2020 09:58:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587401886; cv=pass; d=google.com; s=arc-20160816; b=ZOmvKDhX0S7pL+W4LL14RSGRSYRKagxm3/+eapcamv05Lk9NmRwx+i+jte2Yu0vgIo A/ZurDe+DRn50ks7XYTDEMPKjrEj0k1xDE3adC6fr0FIozwd/wUm5mlH9UCQCosJPTzf zkasehRb6lBkmt7bxXdh/UxyDTp495i1C1lNdqKxcdvKMz33pLgUMxXfRfyh2/JvM2HP K7x/bZIpjeOT3xpjXtoG+JkDgb50jIoAS29F4r/kdvkdqYqPsDRHuoVeedL+s3+qyYB0 y393jDLo8HWQGy5O3WlQZHUPun6hV/FOf6dvN/HMBaYtzIZczMhv1102DZMNq5RkNSST 101w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=YtVj1J7rp8Q7w9yAABkmm75lC4lBOugnhSWn3MWWoio=; b=xIuiqhHa35Ku4a0CFuG5njlZoymiZ1Jx1j1wN+iaYnBK0pioTeTBBSNoIJJy1Wvkmp KwFyE+8RwoeW4BFMlyOjDO8Utz0rJVG8aGHeU7StPysbLKDmbLfOr5Cjzgcza2VY4J2C ovT/VuqIVRJz1UDMZl9SgFMInjoTDLxrgtvRKKK5rPYz9WzuTK32npRBB7nfQ1mJYWp9 b4u2YXA/DEYaCq6I/zD1D/wc3YrJJBPY+oBmvi582/Fw0jpJoc6gvaGq8pxfPuwd3Gpf ufD2wa7elBpWTTwgNtr1h35ziq2l3pzj7ieG22hiV6Ru9L6pLP3ezdZpJkrvBGP3oDSl R8KA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=YtVj1J7rp8Q7w9yAABkmm75lC4lBOugnhSWn3MWWoio=; b=CzcOGbOR65o14xLjT2qdexLcFe9TIgctIVF+HV6sMcprYuACazfr02LeI63rIybVvQ JLCnKKjxymOKnXm4e4y0/tLYhSIYr+1naNBrw8s1wKxla867IofhZXCwEepJpkW0nNSI pR14LpfUDPWZPk3CVNCoAL/15rcQUjV6xxSP5l2ynKdFpRExymJGvjFM0YRey0/P+M1u SgQzUsN4rQYCZNkcXteAVS1W1JLfi/F7QnESWhVv5VaNSNOdbV7HO/89ygZjM+naI86r qtwOKVLlQvZjUqcrhcIAq0kY2SWeTsQLuDgEF0iakBXoKSinFyidVRoncpCyVllISyx0 sqGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=YtVj1J7rp8Q7w9yAABkmm75lC4lBOugnhSWn3MWWoio=; b=t6wjFdD7R7qInGdkJZsNdxlPRZXCBDHr101tRTr27MaDW3uoc7mtrxFydEHBvjckoB 8KMCqODu9/NIjtu6SX4vVIqfuWYTauG0jYIt5b83q4qTmEIOfDzsKCgnTakYZzCgKKve YgdX58pAhSdeV19fCL+p8uIUfG4qqlyR9ZwRmBnq2N9evMf+mso9BPbGMKgNeSJrvo1r nPVooaWJUItV6nO6WNn479B/qimGpLPm8mW56iJgfrfUjUIGskm9/UXfELOoOCmlAmSz 1saxls67IH62ziHXGJm062UvWs+lsqx/GHRjjFptqv3fQ4/bsgMNoZ1Ok4dedYZ+qigt oZqw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AGi0PuaXo7veTCPyJaRwDAqSHfH67iLlrLZhIs8bEFh95myQceZicXIi YS5NPzv7d1Uv7ZGMQPIlC80= X-Google-Smtp-Source: APiQypIXMvB3eZnFbpNYlIaF+8ZYhDgdsA+AdcKPZTZWIUmPyifwOvQdNE0ToVU+L0MX5tIrWPnPfg== X-Received: by 2002:a05:651c:8:: with SMTP id n8mr10640756lja.196.1587401885967; Mon, 20 Apr 2020 09:58:05 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:2002:: with SMTP id s2ls1832609ljo.3.gmail; Mon, 20 Apr 2020 09:58:05 -0700 (PDT) X-Received: by 2002:a2e:800f:: with SMTP id j15mr8523461ljg.27.1587401885248; Mon, 20 Apr 2020 09:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587401885; cv=none; d=google.com; s=arc-20160816; b=Dmw4L/K532oA/HTfynih/SM4ywq8mBMALc/pCn1XVxrrFRGgt2clZCJzuCHro8UQW8 50eT3SQb1GMb4VxDG4edRezGwZ4qpIq0QenNPVdcl3AwD0sutWThTknzuIkTAMRL8sGh UJfBSHYb+uTO0WmOFfWFRRww9jU6gpD1ZZRAK+sTEOHQPRhHqX4bb3MSy4YOIhiDrLTK UwDxeKCvremmZ+T3ymZYJHf97Pj5IOI8cGvPhJQanDXbLmJlLlkjpdX5cbd9vKcnbkmm LW/7Ne9IUv4wzuNzfv5b9A4ccazoiTTm9qb6NsjLS/uUHsTtPWZrzODKI6oG106r9dhy +9Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=boMgTGTL032Hf6NHI7WU4zCGae1VWNXBjstebpM6ZwY=; b=aYPn0tBcvSv8uNItowE4LPCZ7nyOo3R0eIy5NAFRME5VisU5u6HkW/3jts5yDN5Pip jbpu5Gj5hYCnqG5+pkFBmEwbKhLOhyPIy0Eke7EQPLj+lrDhs561nUZTS3CKfe1/n03Y qzxtIZxZZifYu//1hCZ0+hcyFxaT19q4s0nrh9x+coPZOcFfm88XOqJi2mz3kovAVgxh d/igNxJdGHMXcYKWjbK1R7gjAtFJH1wusaLjBqZNO6COUYo3mPjrTshbg5k/b4dFYrsL fpLgPN8Dvn5O3VYYzMqUr2f9wtFMDKe/7g2AJPeBMZXZeAWaiarNh5Wox2wiyIuFUe5J J/3Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id j13si92817lfj.1.2020.04.20.09.58.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2020 09:58:05 -0700 (PDT) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 495XvJ57Lrz1s5VZ; Mon, 20 Apr 2020 18:58:04 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 495XvJ4w18z1qtwY; Mon, 20 Apr 2020 18:58:04 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id CvR5Eod1e160; Mon, 20 Apr 2020 18:58:03 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 20 Apr 2020 18:58:03 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id AC274454053E; Mon, 20 Apr 2020 18:58:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g9cZGMBynnhQ; Mon, 20 Apr 2020 18:58:01 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.38]) by babic.homelinux.org (Postfix) with ESMTP id 1F9854540577; Mon, 20 Apr 2020 18:57:59 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 3/3] Fix coverity #292133 Date: Mon, 20 Apr 2020 18:57:56 +0200 Message-Id: <20200420165756.13275-3-sbabic@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200420165756.13275-1-sbabic@denx.de> References: <20200420165756.13275-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Stefano Babic --- ipc/progress_ipc.c | 6 ++++++ mongoose/mongoose_interface.c | 7 +++++++ suricatta/server_general.c | 8 ++++++++ tools/swupdate-progress.c | 8 ++++++++ tools/swupdate-sysrestart.c | 8 ++++++++ 5 files changed, 37 insertions(+) diff --git a/ipc/progress_ipc.c b/ipc/progress_ipc.c index 49d4b91..b4af883 100644 --- a/ipc/progress_ipc.c +++ b/ipc/progress_ipc.c @@ -44,6 +44,12 @@ static int _progress_ipc_connect(const char *socketpath, bool reconnect) servaddr.sun_family = AF_LOCAL; strncpy(servaddr.sun_path, socketpath, sizeof(servaddr.sun_path) - 1); + /* + * Check to get a valid socket + */ + if (fd < 0) + return -1; + do { if (connect(fd, (struct sockaddr *) &servaddr, sizeof(servaddr)) == 0) { break; diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index 4d2ab52..150210e 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -193,6 +193,13 @@ static void *broadcast_progress_thread(void *data) if (fd < 0) fd = progress_ipc_connect(true); + /* + * if still fails, try later + */ + if (fd < 0) { + sleep(1); + continue; + } ret = progress_ipc_receive(&fd, &msg); if (ret != sizeof(msg)) diff --git a/suricatta/server_general.c b/suricatta/server_general.c index bebbaa6..a099d68 100644 --- a/suricatta/server_general.c +++ b/suricatta/server_general.c @@ -279,6 +279,14 @@ static void *server_progress_thread (void *data) progfd = progress_ipc_connect(true); } + /* + * if still fails, try later + */ + if (progfd < 0) { + sleep(1); + continue; + } + if (progress_ipc_receive(&progfd, &msg) == -1) { continue; } diff --git a/tools/swupdate-progress.c b/tools/swupdate-progress.c index 723d7dc..cd8abd1 100644 --- a/tools/swupdate-progress.c +++ b/tools/swupdate-progress.c @@ -235,6 +235,14 @@ int main(int argc, char **argv) connfd = progress_ipc_connect(opt_w); } + /* + * if still fails, try later + */ + if (connfd < 0) { + sleep(1); + continue; + } + if (progress_ipc_receive(&connfd, &msg) == -1) { continue; } diff --git a/tools/swupdate-sysrestart.c b/tools/swupdate-sysrestart.c index 2435457..31cb29a 100644 --- a/tools/swupdate-sysrestart.c +++ b/tools/swupdate-sysrestart.c @@ -180,6 +180,14 @@ int main(int argc, char **argv) connfd = progress_ipc_connect(opt_w); } + /* + * if still fails, try later + */ + if (connfd < 0) { + sleep(1); + continue; + } + if (progress_ipc_receive(&connfd, &msg) == -1) { continue; }