monitor: Fix potential memory leak

In case l_netlink object was not created successfully, rtmmsg would
leak.
This commit is contained in:
Denis Kenzior 2019-10-17 11:28:11 -05:00
parent 34560120f9
commit 39bb4d07ee
1 changed files with 6 additions and 6 deletions

View File

@ -221,6 +221,12 @@ static struct l_netlink *rtm_interface_send_message(struct l_netlink *rtnl,
return NULL;
}
if (!rtnl)
rtnl = l_netlink_new(NETLINK_ROUTE);
if (!rtnl)
return NULL;
bufsize = NLMSG_LENGTH(sizeof(struct ifinfomsg)) +
RTA_SPACE(ifname_len) + RTA_SPACE(0) +
RTA_SPACE(nlmon_type_len);
@ -231,12 +237,6 @@ static struct l_netlink *rtm_interface_send_message(struct l_netlink *rtnl,
rtmmsg->ifi_family = AF_UNSPEC;
rtmmsg->ifi_change = ~0;
if (!rtnl)
rtnl = l_netlink_new(NETLINK_ROUTE);
if (!rtnl)
return NULL;
rta_buf = rtmmsg + 1;
if (ifname)