mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-06-13 15:45:21 +00:00
genl.c: fix a resource leak found by coverity
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
a741a85d8e
commit
a6537fbbfb
@ -60,45 +60,46 @@ static int genetlink_resolve_family(const char *family)
|
|||||||
|
|
||||||
ret = netlink_open(&handler, NETLINK_GENERIC);
|
ret = netlink_open(&handler, NETLINK_GENERIC);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto out;
|
||||||
|
|
||||||
ret = nla_put_string((struct nlmsg *)&request->nlmsghdr,
|
ret = nla_put_string((struct nlmsg *)&request->nlmsghdr,
|
||||||
CTRL_ATTR_FAMILY_NAME, family);
|
CTRL_ATTR_FAMILY_NAME, family);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out_close;
|
||||||
|
|
||||||
ret = netlink_transaction(&handler, (struct nlmsg *)&request->nlmsghdr,
|
ret = netlink_transaction(&handler, (struct nlmsg *)&request->nlmsghdr,
|
||||||
(struct nlmsg *)&reply->nlmsghdr);
|
(struct nlmsg *)&reply->nlmsghdr);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out_close;
|
||||||
|
|
||||||
genlmsghdr = NLMSG_DATA(&reply->nlmsghdr);
|
genlmsghdr = NLMSG_DATA(&reply->nlmsghdr);
|
||||||
len = reply->nlmsghdr.nlmsg_len;
|
len = reply->nlmsghdr.nlmsg_len;
|
||||||
|
|
||||||
ret = -ENOMSG;
|
ret = -ENOMSG;
|
||||||
if (reply->nlmsghdr.nlmsg_type != GENL_ID_CTRL)
|
if (reply->nlmsghdr.nlmsg_type != GENL_ID_CTRL)
|
||||||
goto out;
|
goto out_close;
|
||||||
|
|
||||||
if (genlmsghdr->cmd != CTRL_CMD_NEWFAMILY)
|
if (genlmsghdr->cmd != CTRL_CMD_NEWFAMILY)
|
||||||
goto out;
|
goto out_close;
|
||||||
|
|
||||||
ret = -EMSGSIZE;
|
ret = -EMSGSIZE;
|
||||||
len -= NLMSG_LENGTH(GENL_HDRLEN);
|
len -= NLMSG_LENGTH(GENL_HDRLEN);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
goto out;
|
goto out_close;
|
||||||
|
|
||||||
attr = (struct nlattr *)GENLMSG_DATA(reply);
|
attr = (struct nlattr *)GENLMSG_DATA(reply);
|
||||||
attr = (struct nlattr *)((char *)attr + NLA_ALIGN(attr->nla_len));
|
attr = (struct nlattr *)((char *)attr + NLA_ALIGN(attr->nla_len));
|
||||||
|
|
||||||
ret = -ENOMSG;
|
ret = -ENOMSG;
|
||||||
if (attr->nla_type != CTRL_ATTR_FAMILY_ID)
|
if (attr->nla_type != CTRL_ATTR_FAMILY_ID)
|
||||||
goto out;
|
goto out_close;
|
||||||
|
|
||||||
ret = *(__u16 *) NLA_DATA(attr);
|
ret = *(__u16 *) NLA_DATA(attr);
|
||||||
|
out_close:
|
||||||
|
netlink_close(&handler);
|
||||||
out:
|
out:
|
||||||
genlmsg_free(request);
|
genlmsg_free(request);
|
||||||
genlmsg_free(reply);
|
genlmsg_free(reply);
|
||||||
netlink_close(&handler);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user