@@ -111,6 +111,10 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
if (rtnl_talk(&rth, &req.n, &answer) < 0) {
get_failed:
+ if (NULL != answer)
+ {
+ free(answer);
+ }
fprintf(stderr,
"Failed to get existing tunnel info.\n");
return -1;
@@ -113,6 +113,10 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
if (rtnl_talk(&rth, &req.n, &answer) < 0) {
get_failed:
+ if (NULL != answer)
+ {
+ free(answer);
+ }
fprintf(stderr,
"Failed to get existing tunnel info.\n");
return -1;
@@ -99,6 +99,10 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
if (rtnl_talk(&rth, &req.n, &answer) < 0) {
get_failed:
+ if (NULL != answer)
+ {
+ free(answer);
+ }
fprintf(stderr,
"Failed to get existing tunnel info.\n");
return -1;
@@ -103,6 +103,10 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv,
if (rtnl_talk(&rth, &req.n, &answer) < 0) {
get_failed:
+ if (NULL != answer)
+ {
+ free(answer);
+ }
fprintf(stderr,
"Failed to get existing tunnel info.\n");
return -1;
@@ -67,6 +67,10 @@ static int vti_parse_opt(struct link_util *lu, int argc, char **argv,
if (rtnl_talk(&rth, &req.n, &answer) < 0) {
get_failed:
+ if (NULL != answer)
+ {
+ free(answer);
+ }
fprintf(stderr,
"Failed to get existing tunnel info.\n");
return -1;
@@ -69,6 +69,10 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv,
if (rtnl_talk(&rth, &req.n, &answer) < 0) {
get_failed:
+ if (NULL != answer)
+ {
+ free(answer);
+ }
fprintf(stderr,
"Failed to get existing tunnel info.\n");
return -1;
The 'rtnl_talk' allocated memory for 'answer', in the exception handling branch, memory should be free, otherwise it will cause memory leak. Signed-off-by: heminhong <heminhong@kylinos.cn> --- ip/link_gre.c | 4 ++++ ip/link_gre6.c | 4 ++++ ip/link_ip6tnl.c | 4 ++++ ip/link_iptnl.c | 4 ++++ ip/link_vti.c | 4 ++++ ip/link_vti6.c | 4 ++++ 6 files changed, 24 insertions(+)