From: Andrea Claudi Date: Fri, 11 Dec 2020 18:53:03 +0000 (+0100) Subject: tc: pedit: fix memory leak in print_pedit X-Git-Tag: v5.10.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d78e8eabf865b47f98adae7c453884bdc19c2f2;p=thirdparty%2Fiproute2.git tc: pedit: fix memory leak in print_pedit 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 Signed-off-by: Stephen Hemminger --- diff --git a/tc/m_pedit.c b/tc/m_pedit.c index 51dcf1093..aa874408c 100644 --- a/tc/m_pedit.c +++ b/tc/m_pedit.c @@ -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.