mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-11-07 04:36:52 -10:00
netlink: Check for NULL return from npt_alloc()
Reviewed by: glebius, pouria Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57171
This commit is contained in:
1 parent
50caa0ea0c
commit
1dbc104148
3 files changed
+9
No files matched your search
@@ -122,6 +122,8 @@ nlmsg_report_cookie_u32(struct nl_pstate *npt, uint32_t val)
|
||||
{
|
||||
struct nlattr *nla = npt_alloc(npt, sizeof(*nla) + sizeof(uint32_t));
|
||||
|
||||
if (nla == NULL)
|
||||
return;
|
||||
nla->nla_type = NLMSGERR_ATTR_COOKIE;
|
||||
nla->nla_len = sizeof(*nla) + sizeof(uint32_t);
|
||||
memcpy(nla + 1, &val, sizeof(uint32_t));
|
||||
|
||||
@@ -155,6 +155,9 @@ _nl_store_ifp_cookie(struct nl_pstate *npt, struct ifnet *ifp)
|
||||
sizeof(ifindex) + NL_ITEM_ALIGN(ifname_len + 1);
|
||||
struct nlattr *nla_cookie = npt_alloc(npt, nla_len);
|
||||
|
||||
if (nla_cookie == NULL)
|
||||
return;
|
||||
|
||||
/* Nested TLV */
|
||||
nla_cookie->nla_len = nla_len;
|
||||
nla_cookie->nla_type = NLMSGERR_ATTR_COOKIE;
|
||||
|
||||
@@ -896,6 +896,10 @@ create_nexthop_from_attrs(struct nl_parsed_route *attrs,
|
||||
int num_nhops = attrs->rta_multipath->num_nhops;
|
||||
struct weightened_nhop *wn = npt_alloc(npt, sizeof(*wn) * num_nhops);
|
||||
|
||||
if (wn == NULL) {
|
||||
*perror = ENOMEM;
|
||||
return (NULL);
|
||||
}
|
||||
for (int i = 0; i < num_nhops; i++) {
|
||||
struct rta_mpath_nh *mpnh = &attrs->rta_multipath->nhops[i];
|
||||
|
||||
|
||||
Reference in new issue
Block a user