From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serhey Popovych Subject: [PATCH iproute2 2/2] ip/tunnel: No need to free answer after rtnl_talk() on error Date: Wed, 20 Dec 2017 09:57:10 +0200 Message-ID: <1513756630-14639-3-git-send-email-serhe.popovych@gmail.com> References: <1513756630-14639-1-git-send-email-serhe.popovych@gmail.com> To: netdev@vger.kernel.org Return-path: Received: from mail-lf0-f65.google.com ([209.85.215.65]:45711 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754439AbdLTH5R (ORCPT ); Wed, 20 Dec 2017 02:57:17 -0500 Received: by mail-lf0-f65.google.com with SMTP id f13so22935240lff.12 for ; Tue, 19 Dec 2017 23:57:16 -0800 (PST) Received: from tuxracer.localdomain ([2a01:6d80::195:20:96:53]) by smtp.gmail.com with ESMTPSA id a7sm1210048lfh.10.2017.12.19.23.57.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Dec 2017 23:57:15 -0800 (PST) In-Reply-To: <1513756630-14639-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 --- ip/link_gre.c | 3 +-- ip/link_gre6.c | 3 +-- ip/link_ip6tnl.c | 3 +-- ip/link_iptnl.c | 3 +-- ip/link_vti.c | 3 +-- ip/link_vti6.c | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ip/link_gre.c b/ip/link_gre.c index 2397920..f55c40c 100644 --- a/ip/link_gre.c +++ b/ip/link_gre.c @@ -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; } diff --git a/ip/link_gre6.c b/ip/link_gre6.c index 7190ada..a3e8e08 100644 --- a/ip/link_gre6.c +++ b/ip/link_gre6.c @@ -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; } diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c index f11ddd5..0a471c2 100644 --- a/ip/link_ip6tnl.c +++ b/ip/link_ip6tnl.c @@ -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; } diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c index 5e4dffa..8a8f5dd 100644 --- a/ip/link_iptnl.c +++ b/ip/link_iptnl.c @@ -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; } diff --git a/ip/link_vti.c b/ip/link_vti.c index 6c5469f..2b0fab2 100644 --- a/ip/link_vti.c +++ b/ip/link_vti.c @@ -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; } diff --git a/ip/link_vti6.c b/ip/link_vti6.c index 4136b0e..74c246d 100644 --- a/ip/link_vti6.c +++ b/ip/link_vti6.c @@ -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; } -- 1.7.10.4