[PATCH] drivers cris: return on NULL dev_alloc_skb()
authorDavid Rientjes <rientjes@cs.washington.edu>
Thu, 9 Nov 2006 03:49:15 +0000 (19:49 -0800)
committerJeff Garzik <jeff@garzik.org>
Fri, 10 Nov 2006 16:08:53 +0000 (11:08 -0500)
If the next descriptor array entry cannot be allocated by dev_alloc_skb(),
return immediately so it is not dereferenced later.  We cannot register the
device with a partial descriptor list.

Cc: Mikael Starvik <starvik@axis.com>
Signed-off-by: David Rientjes <rientjes@cs.washington.edu>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/cris/eth_v10.c

index 966b563..a03d781 100644 (file)
@@ -509,6 +509,8 @@ etrax_ethernet_init(void)
                 * does not share cacheline with any other data (to avoid cache bug)
                 */
                RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
                 * does not share cacheline with any other data (to avoid cache bug)
                 */
                RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
+               if (!RxDescList[i].skb)
+                       return -ENOMEM;
                RxDescList[i].descr.ctrl   = 0;
                RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE;
                RxDescList[i].descr.next   = virt_to_phys(&RxDescList[i + 1]);
                RxDescList[i].descr.ctrl   = 0;
                RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE;
                RxDescList[i].descr.next   = virt_to_phys(&RxDescList[i + 1]);