From: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
To: Pat Gefre <pfg@sgi.com>, akpm@osdl.org, davidm@napali.hpl.hp.com
Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org
Subject: Re: [2.6 PATCH] Altix update
Date: Wed, 18 Feb 2004 18:08:57 +0000 [thread overview]
Message-ID: <200402181908.57797.bzolnier@elka.pw.edu.pl> (raw)
In-Reply-To: <200402181441.i1IEfIWX024531@fsgi900.americas.sgi.com>
[ just a random nitpicking :-) ]
> +/*
> + * sn_alloc_pci_sysdata() - This routine allocates a pci controller
> + * which is expected as the pci_dev and pci_bus sysdata by the Linux
> + * PCI infrastructure.
> + */
> +struct pci_controller *
> +sn_alloc_pci_sysdata(void)
this can be static
> + pci_sysdata = sn_alloc_pci_sysdata();
> + if (!pci_sysdata) {
> + printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to "
> + "allocate memory for pci_sysdata\n");
> + return -ENOMEM;
> + }
> + widget_sysdata = kmalloc(sizeof(struct sn_widget_sysdata),
> + GFP_KERNEL);
> + if (!widget_sysdata) {
> + printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to "
> + "allocate memory for widget_sysdata\n");
> + return -ENOMEM;
> + }
in case of -ENOMEM pci_sysdata is leaked
> + /* Allocate a controller structure */
> + pci_sysdata = sn_alloc_pci_sysdata();
> + if (!pci_sysdata) {
> + printk(KERN_WARNING "sn_pci_fixup_slot: Unable to "
> + "allocate memory for pci_sysdata\n");
> + return -ENOMEM;
> + }
> +
> + /* Set the device vertex */
> + device_sysdata = kmalloc(sizeof(struct sn_device_sysdata), GFP_KERNEL);
> + if (!device_sysdata) {
> + printk(KERN_WARNING "sn_pci_fixup_slot: Unable to "
> + "allocate memory for device_sysdata\n");
> + return -ENOMEM;
> + }
same pci_sysdata leak on error
> + /* Allocate the IORESOURCE_IO space first */
> + for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
> + unsigned long start, end, addr;
> +
> + device_sysdata->pio_map[idx] = NULL;
> +
> + if (!(dev->resource[idx].flags & IORESOURCE_IO))
> + continue;
> +
> + start = dev->resource[idx].start;
> + end = dev->resource[idx].end;
> + size = end - start;
> + if (!size)
> + continue;
> +
> + addr = (unsigned long)pciio_pio_addr(vhdl, 0,
> + PCIIO_SPACE_WIN(idx), 0, size,
> + &device_sysdata->pio_map[idx], 0);
> +
> + if (!addr) {
> + dev->resource[idx].start = 0;
> + dev->resource[idx].end = 0;
> + printk("sn_pci_fixup(): pio map failure for "
> + "%s bar%d\n", dev->slot_name, idx);
> + } else {
> + addr |= __IA64_UNCACHED_OFFSET;
> + dev->resource[idx].start = addr;
> + dev->resource[idx].end = addr + size;
> + }
> +
> + if (dev->resource[idx].flags & IORESOURCE_IO)
> + cmd |= PCI_COMMAND_IO;
> + }
Can dev->resource[idx].flags be modified by pciio_pio_addr()?
If not the last if() is redundant.
> + /* Allocate the IORESOURCE_MEM space next */
> + for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
> + unsigned long start, end, addr;
> +
> + if ((dev->resource[idx].flags & IORESOURCE_IO))
> + continue;
> +
> + start = dev->resource[idx].start;
> + end = dev->resource[idx].end;
> + size = end - start;
> + if (!size)
> + continue;
> +
> + addr = (unsigned long)pciio_pio_addr(vhdl, 0,
> + PCIIO_SPACE_WIN(idx), 0, size,
> + &device_sysdata->pio_map[idx], 0);
> +
> + if (!addr) {
> + dev->resource[idx].start = 0;
> + dev->resource[idx].end = 0;
> + printk("sn_pci_fixup(): pio map failure for "
> + "%s bar%d\n", dev->slot_name, idx);
> + } else {
> + addr |= __IA64_UNCACHED_OFFSET;
> + dev->resource[idx].start = addr;
> + dev->resource[idx].end = addr + size;
> + }
> +
> + if (dev->resource[idx].flags & IORESOURCE_MEM)
> + cmd |= PCI_COMMAND_MEMORY;
> + }
whitespaces damage and spaces vs tabs (there is more in the patch)
IORESOURCE_IO and IORESOURCE_MEM cases beg for common helper function,
static int sn_pci_set_resource(struct pci_dev *dev, unsigned long flag)?
> + /*
> + * Update the Command Word on the Card.
> + */
> + cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */
> + /* bit gets dropped .. no harm */
> + pci_write_config_word(dev, PCI_COMMAND, cmd);
> +
> + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, (unsigned char *)&lines);
> + device_vertex = device_sysdata->vhdl;
> + pci_provider = device_sysdata->pci_provider;
> + device_sysdata->intr_handle = NULL;
> +
> + if (!lines)
> + return 0;
> +
> + irqpdaindr->curr = dev;
> +
> + intr_handle = (pci_provider->intr_alloc)(device_vertex, NULL, lines,
> device_vertex); + if (intr_handle = NULL) {
> + printk(KERN_WARNING "sn_pci_fixup: pcibr_intr_alloc() failed\n");
> + return -ENOMEM;
> + }
pci_sysdata and device_sysdata leak on error
Cheers,
--bart
next prev parent reply other threads:[~2004-02-18 18:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-18 14:41 [2.6 PATCH] Altix update Pat Gefre
2004-02-18 17:06 ` Christoph Hellwig
2004-02-18 18:38 ` David Mosberger
2004-02-18 18:44 ` Christoph Hellwig
2004-02-18 19:00 ` David Mosberger
2004-02-18 19:15 ` Christoph Hellwig
2004-02-18 19:27 ` David Mosberger
2004-02-18 17:47 ` David Mosberger
2004-02-18 18:08 ` Bartlomiej Zolnierkiewicz [this message]
2004-02-18 19:57 ` David Mosberger
2004-02-19 18:09 ` Pat Gefre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200402181908.57797.bzolnier@elka.pw.edu.pl \
--to=b.zolnierkiewicz@elka.pw.edu.pl \
--cc=akpm@osdl.org \
--cc=davidm@napali.hpl.hp.com \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pfg@sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox