mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-06-12 16:29:54 +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);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto out;
|
||||
|
||||
ret = nla_put_string((struct nlmsg *)&request->nlmsghdr,
|
||||
CTRL_ATTR_FAMILY_NAME, family);
|
||||
if (ret)
|
||||
goto out;
|
||||
goto out_close;
|
||||
|
||||
ret = netlink_transaction(&handler, (struct nlmsg *)&request->nlmsghdr,
|
||||
(struct nlmsg *)&reply->nlmsghdr);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
goto out_close;
|
||||
|
||||
genlmsghdr = NLMSG_DATA(&reply->nlmsghdr);
|
||||
len = reply->nlmsghdr.nlmsg_len;
|
||||
|
||||
ret = -ENOMSG;
|
||||
if (reply->nlmsghdr.nlmsg_type != GENL_ID_CTRL)
|
||||
goto out;
|
||||
goto out_close;
|
||||
|
||||
if (genlmsghdr->cmd != CTRL_CMD_NEWFAMILY)
|
||||
goto out;
|
||||
goto out_close;
|
||||
|
||||
ret = -EMSGSIZE;
|
||||
len -= NLMSG_LENGTH(GENL_HDRLEN);
|
||||
if (len < 0)
|
||||
goto out;
|
||||
goto out_close;
|
||||
|
||||
attr = (struct nlattr *)GENLMSG_DATA(reply);
|
||||
attr = (struct nlattr *)((char *)attr + NLA_ALIGN(attr->nla_len));
|
||||
|
||||
ret = -ENOMSG;
|
||||
if (attr->nla_type != CTRL_ATTR_FAMILY_ID)
|
||||
goto out;
|
||||
goto out_close;
|
||||
|
||||
ret = *(__u16 *) NLA_DATA(attr);
|
||||
out_close:
|
||||
netlink_close(&handler);
|
||||
out:
|
||||
genlmsg_free(request);
|
||||
genlmsg_free(reply);
|
||||
netlink_close(&handler);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user