From: Alexey Dobriyan Date: Mon, 26 Feb 2007 00:31:58 +0000 (+0100) Subject: [IPV4/IPV6] multicast: Check add_grhead() return value X-Git-Tag: v2.6.16.43-rc1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=666ebed8390d4cf3d0411163c6c2e0098e6a148e;p=thirdparty%2Fkernel%2Fstable.git [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. Adrian Bunk: backported to 2.6.16 Signed-off-by: Alexey Dobriyan Signed-off-by: David S. Miller Signed-off-by: Adrian Bunk --- diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 64ce52bf0485a..39e30c79f25c8 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -456,6 +456,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, skb = add_grhead(skb, pmc, type, &pgr); first = 0; } + if (!skb) + return NULL; psrc = (u32 *)skb_put(skb, sizeof(u32)); *psrc = psf->sf_inaddr; scount++; stotal++; diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index c75cd1c4d6b89..0470a18922f7a 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c @@ -1582,6 +1582,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc, skb = add_grhead(skb, pmc, type, &pgr); first = 0; } + if (!skb) + return NULL; psrc = (struct in6_addr *)skb_put(skb, sizeof(*psrc)); *psrc = psf->sf_addr; scount++; stotal++;