]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
tc: pedit: fix memory leak in print_pedit
authorAndrea Claudi <aclaudi@redhat.com>
Fri, 11 Dec 2020 18:53:03 +0000 (19:53 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 14 Dec 2020 17:24:08 +0000 (09:24 -0800)
keys_ex is dinamically allocated with calloc on line 770, but
is not freed in case of error at line 823.

Fixes: 081d6c310d3a ("tc: pedit: Support JSON dumping")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/m_pedit.c

index 51dcf10930e812a264481d914ec7efb54cecfd9c..aa874408c51be720a685ffa61ac18b7dc7d009c0 100644 (file)
@@ -819,8 +819,10 @@ static int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
                        print_uint(PRINT_FP, NULL, "\n\t key #%d  at ", i);
 
                        err = print_pedit_location(f, htype, key->off);
-                       if (err)
+                       if (err) {
+                               free(keys_ex);
                                return err;
+                       }
 
                        /* In FP, report the "set" command as "val" to keep
                         * backward compatibility. Report the true name in JSON.