瀏覽代碼

[PATCH] skge: check the allocation of ring buffer

The SysKonnect Genesis and Yukon chip sets have restrictions on the possible
control block area.  The memory needs to not cross 4 Gig boundary, and it needs
to be 8 byte aligned.  This patch checks and fails to bring the device up
if region is unacceptable.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Stephen Hemminger 19 年之前
父節點
當前提交
c3da144740
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      drivers/net/skge.c

+ 9 - 1
drivers/net/skge.c

@@ -727,7 +727,7 @@ static struct ethtool_ops skge_ethtool_ops = {
  * Allocate ring elements and chain them together
  * Allocate ring elements and chain them together
  * One-to-one association of board descriptors with ring elements
  * One-to-one association of board descriptors with ring elements
  */
  */
-static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u64 base)
+static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
 {
 {
 	struct skge_tx_desc *d;
 	struct skge_tx_desc *d;
 	struct skge_element *e;
 	struct skge_element *e;
@@ -2168,6 +2168,14 @@ static int skge_up(struct net_device *dev)
 	if (!skge->mem)
 	if (!skge->mem)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
+	BUG_ON(skge->dma & 7);
+
+	if ((u64)skge->dma >> 32 != ((u64) skge->dma + skge->mem_size) >> 32) {
+		printk(KERN_ERR PFX "pci_alloc_consistent region crosses 4G boundary\n");
+		err = -EINVAL;
+		goto free_pci_mem;
+	}
+
 	memset(skge->mem, 0, skge->mem_size);
 	memset(skge->mem, 0, skge->mem_size);
 
 
 	if ((err = skge_ring_alloc(&skge->rx_ring, skge->mem, skge->dma)))
 	if ((err = skge_ring_alloc(&skge->rx_ring, skge->mem, skge->dma)))