Commit cc63f70b authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by David S. Miller

[IPV4/IPV6] multicast: Check add_grhead() return value

add_grhead() allocates memory with GFP_ATOMIC and in at least two places skb
from it passed to skb_put() without checking.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f2f2102d
...@@ -455,6 +455,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, ...@@ -455,6 +455,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
skb = add_grhead(skb, pmc, type, &pgr); skb = add_grhead(skb, pmc, type, &pgr);
first = 0; first = 0;
} }
if (!skb)
return NULL;
psrc = (__be32 *)skb_put(skb, sizeof(__be32)); psrc = (__be32 *)skb_put(skb, sizeof(__be32));
*psrc = psf->sf_inaddr; *psrc = psf->sf_inaddr;
scount++; stotal++; scount++; stotal++;
......
...@@ -1582,6 +1582,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc, ...@@ -1582,6 +1582,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
skb = add_grhead(skb, pmc, type, &pgr); skb = add_grhead(skb, pmc, type, &pgr);
first = 0; first = 0;
} }
if (!skb)
return NULL;
psrc = (struct in6_addr *)skb_put(skb, sizeof(*psrc)); psrc = (struct in6_addr *)skb_put(skb, sizeof(*psrc));
*psrc = psf->sf_addr; *psrc = psf->sf_addr;
scount++; stotal++; scount++; stotal++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment