All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	stable@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>,
	Remy Horton <remy.horton@intel.com>
Subject: [PATCH v2 11/13] examples/ethtool: fix exit flag and unchecked cmdline
Date: Mon,  7 Sep 2026 10:03:29 -0700	[thread overview]
Message-ID: <20260907170454.351647-12-stephen@networkplumber.org> (raw)
In-Reply-To: <20260907170454.351647-1-stephen@networkplumber.org>

The exit_now flag is polled by worker_main() on one lcore and set by
main() on another, but is a plain int so the load can be hoisted out
of the loop. Make it volatile.

Also check the cmdline_stdin_new() result before using it.

Found by gcc -fanalyzer.

Fixes: bda68ab9d1e7 ("examples/ethtool: add user-space ethtool sample application")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 examples/ethtool/ethtool-app/ethapp.c | 5 +++++
 examples/ethtool/ethtool-app/main.c   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 489cd4f515..68c8a29b96 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -4,6 +4,8 @@
 
 #include <stdlib.h>
 
+#include <rte_debug.h>
+
 #include <cmdline_parse.h>
 #include <cmdline_parse_num.h>
 #include <cmdline_parse_string.h>
@@ -914,6 +916,9 @@ void ethapp_main(void)
 	struct cmdline *ctx_cmdline;
 
 	ctx_cmdline = cmdline_stdin_new(list_prompt_commands, "EthApp> ");
+	if (ctx_cmdline == NULL)
+		rte_panic("Cannot create cmdline instance\n");
+
 	cmdline_interact(ctx_cmdline);
 	cmdline_stdin_exit(ctx_cmdline);
 }
diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c
index 6545eb322d..ddd256cd7b 100644
--- a/examples/ethtool/ethtool-app/main.c
+++ b/examples/ethtool/ethtool-app/main.c
@@ -44,7 +44,7 @@ struct app_port {
 struct app_config {
 	struct app_port ports[MAX_PORTS];
 	int cnt_ports;
-	int exit_now;
+	volatile int exit_now;
 };
 
 
-- 
2.53.0


  parent reply	other threads:[~2026-09-07 17:06 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 23:24 [PATCH 00/13] make signal handlers async-signal-safe Stephen Hemminger
2026-09-06 23:24 ` [PATCH 01/13] graph: do not call printf in signal Stephen Hemminger
2026-09-06 23:24 ` [PATCH 02/13] examples: remove printf from signal handler Stephen Hemminger
2026-09-06 23:24 ` [PATCH 03/13] examples/vmdq: do not print " Stephen Hemminger
2026-09-06 23:24 ` [PATCH 04/13] examples/symmetric_mp: do not print or exit in handler Stephen Hemminger
2026-09-06 23:24 ` [PATCH 05/13] examples/vdpa: make signal handler safe Stephen Hemminger
2026-09-06 23:24 ` [PATCH 06/13] examples/vhost: " Stephen Hemminger
2026-09-06 23:24 ` [PATCH 07/13] examples/vhost_blk: do not tear down from signal handler Stephen Hemminger
2026-09-06 23:24 ` [PATCH 08/13] examples/ntb: do not print and re-raise " Stephen Hemminger
2026-09-06 23:24 ` [PATCH 09/13] examples/ipsecgw: do not print " Stephen Hemminger
2026-09-08 11:19   ` Radu Nicolau
2026-09-06 23:24 ` [PATCH 10/13] examples/l2fwd-macsec: remove print in " Stephen Hemminger
2026-09-06 23:24 ` [PATCH 11/13] examples/ethtool: fix exit flag and unchecked cmdline Stephen Hemminger
2026-09-06 23:24 ` [PATCH 12/13] examples/vmdq_dcb: allow exit on signal Stephen Hemminger
2026-09-06 23:24 ` [PATCH 13/13] examples/eventdev_pipeline: make signal handler safe Stephen Hemminger
2026-09-07  9:06 ` [PATCH 00/13] make signal handlers async-signal-safe Bruce Richardson
2026-09-07 17:03 ` [PATCH v2 " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 01/13] graph: do not call printf in signal Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 02/13] examples: remove printf from signal handler Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 03/13] examples/vmdq: do not print " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 04/13] examples/symmetric_mp: do not print or exit in handler Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 05/13] examples/vdpa: make signal handler safe Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 06/13] examples/vhost: " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 07/13] examples/vhost_blk: do not tear down from signal handler Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 08/13] examples/ntb: do not print and re-raise " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 09/13] examples/ipsecgw: do not print " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 10/13] examples/l2fwd-macsec: remove print in " Stephen Hemminger
2026-09-07 17:03   ` Stephen Hemminger [this message]
2026-09-07 17:03   ` [PATCH v2 12/13] examples/vmdq_dcb: allow exit on signal Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 13/13] examples/eventdev_pipeline: make signal handler safe Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260907170454.351647-12-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=remy.horton@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.