]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iproute2: prevent memory leak on error return
authorheminhong <heminhong@kylinos.cn>
Tue, 14 Nov 2023 08:13:07 +0000 (16:13 +0800)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 29 Nov 2023 04:47:02 +0000 (20:47 -0800)
When rtnl_statsdump_req_filter() or rtnl_dump_filter() failed to process,
just return will cause memory leak.

Signed-off-by: heminhong <heminhong@kylinos.cn>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/iplink.c

index 9a548dd35f54bcfef81ca8ae74d7702227bf437e..c7e5021c5d3a242759deceaed591543124884614 100644 (file)
@@ -1722,11 +1722,13 @@ static int iplink_afstats(int argc, char **argv)
        if (rtnl_statsdump_req_filter(&rth, AF_UNSPEC, filt_mask,
                                      NULL, NULL) < 0) {
                perror("Cannont send dump request");
+               delete_json_obj();
                return 1;
        }
 
        if (rtnl_dump_filter(&rth, print_af_stats, &ctx) < 0) {
                fprintf(stderr, "Dump terminated\n");
+               delete_json_obj();
                return 1;
        }