Message ID | 20241125073147.68399-1-heminhong@kylinos.cn (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | bridge: fix memory leak in error path | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On 25/11/2024 09:31, Minhong He wrote: > When 'rtnl_dump_filter()' fails to process, it will cause memory leak. > > Signed-off-by: Minhong He <heminhong@kylinos.cn> > --- > bridge/mst.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > Please CC bridge maintainers on related patches. This is a patch for iproute2 and should have it in the subject (e.g. PATCH iproute2). Also there's undocumented and unrelated cosmetic fix (removal of extra tab below). > 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); > - > + This change is not documented and unrelated cosmetic fix. > if (state < 0 || state > UINT8_MAX) { > fprintf(stderr, "Error: invalid STP port state\n"); > return -1;
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;
When 'rtnl_dump_filter()' fails to process, it will cause memory leak. Signed-off-by: Minhong He <heminhong@kylinos.cn> --- bridge/mst.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)