qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: sfeldma@gmail.com
Cc: jiri@resnulli.us, roopa@cumulusnetworks.com,
	john.fastabend@gmail.com, qemu-devel@nongnu.org,
	dsahern@gmail.com, pbonzini@redhat.com, jasowang@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 06/10] rocker: add new rocker switch device
Date: Mon, 2 Feb 2015 18:12:24 +0100	[thread overview]
Message-ID: <20150202171224.GD10862@stefanha-thinkpad> (raw)
In-Reply-To: <1421913839-22448-7-git-send-email-sfeldma@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1870 bytes --]

On Thu, Jan 22, 2015 at 12:03:55AM -0800, sfeldma@gmail.com wrote:
> +        iov[iovcnt].iov_len = frag_len;
> +        iov[iovcnt].iov_base = g_malloc(frag_len);
> +        if (!iov[iovcnt].iov_base) {
> +            err = -ROCKER_ENOMEM;
> +            goto err_no_mem;
> +        }
> +
> +        if (pci_dma_read(dev, frag_addr, iov[iovcnt].iov_base,
> +                     iov[iovcnt].iov_len)) {
> +            err = -ROCKER_ENXIO;
> +            goto err_bad_io;
> +        }

iov[iovcnt].iov_base is leaked because iovcnt hasn't been incremented
yet.  The cleanup loop will not free this fragment.

> +static void rocker_test_dma_ctrl(Rocker *r, uint32_t val)
> +{
> +    PCIDevice *dev = PCI_DEVICE(r);
> +    char *buf;
> +    int i;
> +
> +    buf = malloc(r->test_dma_size);

Please use g_try_malloc()

> +
> +    if (!buf) {
> +        DPRINTF("test dma buffer alloc failed");
> +        return;
> +    }
> +
> +    switch (val) {
> +    case ROCKER_TEST_DMA_CTRL_CLEAR:
> +        memset(buf, 0, r->test_dma_size);
> +        break;
> +    case ROCKER_TEST_DMA_CTRL_FILL:
> +        memset(buf, 0x96, r->test_dma_size);
> +        break;
> +    case ROCKER_TEST_DMA_CTRL_INVERT:
> +        pci_dma_read(dev, r->test_dma_addr, buf, r->test_dma_size);
> +        for (i = 0; i < r->test_dma_size; i++) {
> +            buf[i] = ~buf[i];
> +        }
> +        break;
> +    default:
> +        DPRINTF("not test dma control val=0x%08x\n", val);
> +        return;
> +    }
> +    pci_dma_write(dev, r->test_dma_addr, buf, r->test_dma_size);
> +
> +    rocker_msix_irq(r, ROCKER_MSIX_VEC_TEST);
> +}

Where is buf freed?

> +void fp_port_set_macaddr(FpPort *port, MACAddr *macaddr)
> +{
> +/*XXX memcpy(port->conf.macaddr.a, macaddr.a, sizeof(port->conf.macaddr.a)); */
> +}

What's missing here?


I didn't review the OF DPA code but the rest looks good.

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-02-03  9:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-22  8:03 [Qemu-devel] [PATCH v5 00/10] rocker: add new rocker ethernet switch device sfeldma
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 01/10] net: add MAC address string printer sfeldma
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 02/10] virtio-net: use qemu_mac_strdup_printf sfeldma
2015-02-03 16:19   ` Eric Blake
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 03/10] rocker: add register programming guide sfeldma
2015-02-02 16:16   ` Stefan Hajnoczi
2015-02-02 16:19   ` Stefan Hajnoczi
2015-02-03 11:08     ` Paolo Bonzini
2015-02-05 10:45       ` Stefan Hajnoczi
2015-02-05  6:29     ` Scott Feldman
2015-02-03 16:40   ` Eric Blake
2015-02-05  6:25     ` Scott Feldman
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 04/10] pci: add rocker device ID sfeldma
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 05/10] pci: add network device class 'other' for network switches sfeldma
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 06/10] rocker: add new rocker switch device sfeldma
2015-02-02 17:12   ` Stefan Hajnoczi [this message]
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 07/10] qmp: add rocker device support sfeldma
2015-02-03 15:10   ` Eric Blake
2015-02-05  6:10     ` Scott Feldman
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 08/10] rocker: add tests sfeldma
2015-02-02 16:36   ` Stefan Hajnoczi
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 09/10] MAINTAINERS: add rocker sfeldma
2015-01-22  8:03 ` [Qemu-devel] [PATCH v5 10/10] rocker: timestamp on the debug logs helps correlate with events in the VM sfeldma
2015-01-22  8:21   ` Jiri Pirko
2015-02-02 17:13 ` [Qemu-devel] [PATCH v5 00/10] rocker: add new rocker ethernet switch device Stefan Hajnoczi

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=20150202171224.GD10862@stefanha-thinkpad \
    --to=stefanha@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=john.fastabend@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=roopa@cumulusnetworks.com \
    --cc=sfeldma@gmail.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;
as well as URLs for NNTP newsgroup(s).