When the return value of rtnl_talk() is greater than
or equal to 0, 'answer' will be allocated.
The 'answer' should be free after using,
otherwise it will cause memory leak.
Signed-off-by: Minhong He <heminhong@kylinos.cn>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
struct rtattr *tb[IFLA_MAX + 1];
struct rtnl_handle rth;
struct ifinfomsg *ifi;
- struct nlmsghdr *n;
+ struct nlmsghdr *n = NULL;
int len;
int err;
err = ifname_map_rtnl_port_parse(dl, ifname, tb[IFLA_DEVLINK_PORT]);
out:
+ free(n);
rtnl_close(&rth);
return err;
}