From fac023017a35216cb7c3cfe383aeade7d3c3a097 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 18 Jan 2004 18:51:24 -0800 Subject: [PATCH] [PATCH] sn: Fixed an oom in pci_bus_cvlink.c From: Pat Gefre Fixed an oom in pci_bus_cvlink.c Also added slot to flush code --- arch/ia64/sn/io/machvec/pci_bus_cvlink.c | 12 +++++++++++- include/asm-ia64/sn/pci/pcibr_private.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/ia64/sn/io/machvec/pci_bus_cvlink.c b/arch/ia64/sn/io/machvec/pci_bus_cvlink.c index 4e16ea113087b..2e99647c960b3 100644 --- a/arch/ia64/sn/io/machvec/pci_bus_cvlink.c +++ b/arch/ia64/sn/io/machvec/pci_bus_cvlink.c @@ -213,6 +213,10 @@ sn_dma_flush_init(unsigned long start, unsigned long end, int idx, int pin, int if (flush_nasid_list[nasid].widget_p == NULL) { flush_nasid_list[nasid].widget_p = (struct sn_flush_device_list **)kmalloc((HUB_WIDGET_ID_MAX+1) * sizeof(struct sn_flush_device_list *), GFP_KERNEL); + if (flush_nasid_list[nasid].widget_p <= 0) { + printk("sn_dma_flush_init: Cannot allocate memory for nasid list\n"); + return; + } memset(flush_nasid_list[nasid].widget_p, 0, (HUB_WIDGET_ID_MAX+1) * sizeof(struct sn_flush_device_list *)); } if (bwin > 0) { @@ -240,22 +244,28 @@ sn_dma_flush_init(unsigned long start, unsigned long end, int idx, int pin, int if (flush_nasid_list[nasid].widget_p[wid_num] == NULL) { flush_nasid_list[nasid].widget_p[wid_num] = (struct sn_flush_device_list *)kmalloc( DEV_PER_WIDGET * sizeof (struct sn_flush_device_list), GFP_KERNEL); + if (flush_nasid_list[nasid].widget_p[wid_num] <= 0) { + printk("sn_dma_flush_init: Cannot allocate memory for nasid sub-list\n"); + return; + } memset(flush_nasid_list[nasid].widget_p[wid_num], 0, DEV_PER_WIDGET * sizeof (struct sn_flush_device_list)); p = &flush_nasid_list[nasid].widget_p[wid_num][0]; for (i=0; ibus = -1; p->pin = -1; + p->slot = -1; p++; } } p = &flush_nasid_list[nasid].widget_p[wid_num][0]; for (i=0;ipin == pin && p->bus == bus) break; + if (p->pin == pin && p->bus == bus && p->slot == slot) break; if (p->pin < 0) { p->pin = pin; p->bus = bus; + p->slot = slot; break; } p++; diff --git a/include/asm-ia64/sn/pci/pcibr_private.h b/include/asm-ia64/sn/pci/pcibr_private.h index 4722c69e2220c..efc9fc59c7fc8 100644 --- a/include/asm-ia64/sn/pci/pcibr_private.h +++ b/include/asm-ia64/sn/pci/pcibr_private.h @@ -702,6 +702,7 @@ struct pcibr_list_s { struct sn_flush_device_list { int bus; + int slot; int pin; struct bar_list { unsigned long start; -- 2.53.0