[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241125073147.68399-1-heminhong@kylinos.cn>
Date: Mon, 25 Nov 2024 15:31:47 +0800
From: Minhong He <heminhong@...inos.cn>
To: stephen@...workplumber.org,
netdev@...r.kernel.org
Cc: Minhong He <heminhong@...inos.cn>
Subject: [PATCH] bridge: fix memory leak in error path
When 'rtnl_dump_filter()' fails to process, it will cause memory leak.
Signed-off-by: Minhong He <heminhong@...inos.cn>
---
bridge/mst.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bridge/mst.c b/bridge/mst.c
index 32f64aba..a85e6188 100644
--- a/bridge/mst.c
+++ b/bridge/mst.c
@@ -153,6 +153,7 @@ static int mst_show(int argc, char **argv)
if (rtnl_dump_filter(&rth, print_msts, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
+ delete_json_obj();
return -1;
}
@@ -214,7 +215,7 @@ static int mst_set(int argc, char **argv)
state = strtol(s, &endptr, 10);
if (!(*s != '\0' && *endptr == '\0'))
state = parse_stp_state(s);
-
+
if (state < 0 || state > UINT8_MAX) {
fprintf(stderr, "Error: invalid STP port state\n");
return -1;
--
2.25.1
Powered by blists - more mailing lists