All of lore.kernel.org
 help / color / mirror / Atom feed
From: sunsuwan <sunsuwan3@huawei.com>
To: <netdev@vger.kernel.org>
Cc: <sunsuwan3@huawei.com>, <chenzhen126@huawei.com>,
	<liaichun@huawei.com>, <yanan@huawei.com>, <roopa@nvidia.com>,
	<nikolay@nvidia.com>, <davem@davemloft.net>, <kuba@kernel.org>
Subject: [PATCH] bridge-utils:close socket before exit
Date: Wed, 3 Aug 2022 16:20:51 +0800	[thread overview]
Message-ID: <20220803082051.1704227-1-sunsuwan3@huawei.com> (raw)

brctl should close socket before exit.

Signed-off-by: sunsuwan <sunsuwan3@huawei.com>

---
 brctl/brctl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/brctl/brctl.c b/brctl/brctl.c
index 8855234..dd6c347 100644
--- a/brctl/brctl.c
+++ b/brctl/brctl.c
@@ -37,7 +37,7 @@ static void help()
 int main(int argc, char *const* argv)
 {
 	const struct command *cmd;
-	int f;
+	int f, ret;
 	static const struct option options[] = {
 		{ .name = "help", .val = 'h' },
 		{ .name = "version", .val = 'V' },
@@ -70,16 +70,20 @@ int main(int argc, char *const* argv)
 	argv += optind;
 	if ((cmd = command_lookup(*argv)) == NULL) {
 		fprintf(stderr, "never heard of command [%s]\n", *argv);
+		br_shutdown();
 		goto help;
 	}
 	
 	if (argc < cmd->nargs + 1) {
 		printf("Incorrect number of arguments for command\n");
 		printf("Usage: brctl %s %s\n", cmd->name, cmd->help);
+		br_shutdown();
 		return 1;
 	}
 
-	return cmd->func(argc, argv);
+	ret = cmd->func(argc, argv);
+	br_shutdown();
+	return ret;
 
 help:
 	help();
-- 
2.30.0


             reply	other threads:[~2022-08-03  8:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03  8:20 sunsuwan [this message]
2022-08-03 15:25 ` [PATCH] bridge-utils:close socket before exit 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=20220803082051.1704227-1-sunsuwan3@huawei.com \
    --to=sunsuwan3@huawei.com \
    --cc=chenzhen126@huawei.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=liaichun@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=roopa@nvidia.com \
    --cc=yanan@huawei.com \
    /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.