]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip/tunnel: No need to free answer after rtnl_talk() on error
authorSerhey Popovych <serhe.popovych@gmail.com>
Wed, 20 Dec 2017 07:57:10 +0000 (09:57 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 26 Dec 2017 17:07:43 +0000 (09:07 -0800)
Since rtnl_talk() never returns with answer buffer allocated
on error we do not need to release it manually. After this
initializing answer with NULL before rtnl_talk() is useless.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
ip/link_gre.c
ip/link_gre6.c
ip/link_ip6tnl.c
ip/link_iptnl.c
ip/link_vti.c
ip/link_vti6.c

index 2397920a4e65cda71d80d188428c10de09b72ed4..f55c40c71a68f0d49890179bd11e01f36153a47e 100644 (file)
@@ -75,7 +75,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
                .i.ifi_family = preferred_family,
                .i.ifi_index = ifi->ifi_index,
        };
-       struct nlmsghdr *answer = NULL;
+       struct nlmsghdr *answer;
        struct rtattr *tb[IFLA_MAX + 1];
        struct rtattr *linkinfo[IFLA_INFO_MAX+1];
        struct rtattr *greinfo[IFLA_GRE_MAX + 1];
@@ -104,7 +104,6 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
 get_failed:
                        fprintf(stderr,
                                "Failed to get existing tunnel info.\n");
-                       free(answer);
                        return -1;
                }
 
index 7190ada93c29dddc119f3fda1ac691df9d9fc979..a3e8e088378ed11c060ede62c789aa59b695e0a7 100644 (file)
@@ -86,7 +86,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
                .i.ifi_family = preferred_family,
                .i.ifi_index = ifi->ifi_index,
        };
-       struct nlmsghdr *answer = NULL;
+       struct nlmsghdr *answer;
        struct rtattr *tb[IFLA_MAX + 1];
        struct rtattr *linkinfo[IFLA_INFO_MAX+1];
        struct rtattr *greinfo[IFLA_GRE_MAX + 1];
@@ -114,7 +114,6 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
 get_failed:
                        fprintf(stderr,
                                "Failed to get existing tunnel info.\n");
-                       free(answer);
                        return -1;
                }
 
index f11ddd597da49f50befc577f0f7e9b25ccfe5eab..0a471c2d988089fb2838363e31768c20b33d559d 100644 (file)
@@ -83,7 +83,7 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
                .i.ifi_family = preferred_family,
                .i.ifi_index = ifi->ifi_index,
        };
-       struct nlmsghdr *answer = NULL;
+       struct nlmsghdr *answer;
        struct rtattr *tb[IFLA_MAX + 1];
        struct rtattr *linkinfo[IFLA_INFO_MAX+1];
        struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1];
@@ -108,7 +108,6 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
 get_failed:
                        fprintf(stderr,
                                "Failed to get existing tunnel info.\n");
-                       free(answer);
                        return -1;
                }
 
index 5e4dffa60ef1d46c900eaa970c0d4eec493702f6..8a8f5dd0dfc50ab5c459021d3cd4ab7e2ad105ad 100644 (file)
@@ -83,7 +83,7 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv,
                .i.ifi_family = preferred_family,
                .i.ifi_index = ifi->ifi_index,
        };
-       struct nlmsghdr *answer = NULL;
+       struct nlmsghdr *answer;
        struct rtattr *tb[IFLA_MAX + 1];
        struct rtattr *linkinfo[IFLA_INFO_MAX+1];
        struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1];
@@ -112,7 +112,6 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv,
 get_failed:
                        fprintf(stderr,
                                "Failed to get existing tunnel info.\n");
-                       free(answer);
                        return -1;
                }
 
index 6c5469ff8d608685234d9ea16f52e0108a812a47..2b0fab27dbf46b037b3a162684ddeaee2397c23a 100644 (file)
@@ -60,7 +60,7 @@ static int vti_parse_opt(struct link_util *lu, int argc, char **argv,
                .i.ifi_family = preferred_family,
                .i.ifi_index = ifi->ifi_index,
        };
-       struct nlmsghdr *answer = NULL;
+       struct nlmsghdr *answer;
        struct rtattr *tb[IFLA_MAX + 1];
        struct rtattr *linkinfo[IFLA_INFO_MAX+1];
        struct rtattr *vtiinfo[IFLA_VTI_MAX + 1];
@@ -77,7 +77,6 @@ static int vti_parse_opt(struct link_util *lu, int argc, char **argv,
 get_failed:
                        fprintf(stderr,
                                "Failed to get existing tunnel info.\n");
-                       free(answer);
                        return -1;
                }
 
index 4136b0e7a526aef9147f7417e7d548b14ffac2da..74c246d3ed86bb2ef55f679d21980fe3dd24c879 100644 (file)
@@ -55,7 +55,7 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv,
                .i.ifi_family = preferred_family,
                .i.ifi_index = ifi->ifi_index,
        };
-       struct nlmsghdr *answer = NULL;
+       struct nlmsghdr *answer;
        struct rtattr *tb[IFLA_MAX + 1];
        struct rtattr *linkinfo[IFLA_INFO_MAX+1];
        struct rtattr *vtiinfo[IFLA_VTI_MAX + 1];
@@ -72,7 +72,6 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv,
 get_failed:
                        fprintf(stderr,
                                "Failed to get existing tunnel info.\n");
-                       free(answer);
                        return -1;
                }