From: Russell King - ARM Linux <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
To: Dann Frazier <dann.frazier-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Cc: Iyappan Subramanian <isubramanian-qTEPVZfXA3Y@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
jcm-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
patches-qTEPVZfXA3Y@public.gmane.org,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Keyur Chudgar <kchudgar-qTEPVZfXA3Y@public.gmane.org>,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Ravi Patel <rapatel-qTEPVZfXA3Y@public.gmane.org>
Subject: Re: [PATCH v8 4/4] drivers: net: Add APM X-Gene SoC ethernet driver support.
Date: Thu, 26 Jun 2014 00:04:50 +0100 [thread overview]
Message-ID: <20140625230450.GO32514@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CALdTtnvHt5mYMC3619E4F3KK0jPOw7mCpKE6bTn0Um6fdZ4rbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Tue, Jun 24, 2014 at 10:29:48PM -0600, Dann Frazier wrote:
> On Fri, Jun 20, 2014 at 5:18 PM, Iyappan Subramanian
> <isubramanian-qTEPVZfXA3Y@public.gmane.org> wrote:
> > + ring->desc_addr = dma_zalloc_coherent(dev, size, &ring->dma,
> > + GFP_KERNEL);
>
> Iyappan,
> When testing this driver on a 3.16-rc2 base, I'm finding that
> desc_addr gets assigned to NULL here, which results in an oops later
> on (see below).
Note that on failure here...
> > + if (!ring->desc_addr)
> > + goto err;
we jump to 'err'.
> > +err:
> > + dma_free_coherent(dev, size, ring->desc_addr, ring->dma);
which then tries to call dma_free_coherent on a NULL pointer, and
possibly undefined ring->dma value. That's not a nice thing to do,
and will probably lead to problems. I know that none of the ARM
flavours of this function will handle this gracefully, and neither
does x86's version either. So this is very probably illegal.
> > +static int xgene_enet_create_desc_rings(struct net_device *ndev)
> > +{
> > + struct xgene_enet_pdata *pdata = netdev_priv(ndev);
> > + struct device *dev = &pdata->pdev->dev;
> > + struct xgene_enet_desc_ring *rx_ring, *tx_ring, *cp_ring;
> > + struct xgene_enet_desc_ring *buf_pool = NULL;
> > + u8 cpu_bufnum = 0, eth_bufnum = 0;
> > + u8 bp_bufnum = 0x20;
> > + u16 ring_id, ring_num = 0;
> > + int ret;
> > +
> > + /* allocate rx descriptor ring */
> > + ring_id = xgene_enet_get_ring_id(RING_OWNER_CPU, cpu_bufnum++);
> > + rx_ring = xgene_enet_create_desc_ring(ndev, ring_num++,
> > + RING_CFGSIZE_16KB, ring_id);
> > + if (IS_ERR_OR_NULL(rx_ring)) {
> > + ret = PTR_ERR(rx_ring);
> > + goto err;
> > + }
>
> Here we test for IS_ERR_OR_NULL. In the oops I'm hitting, rx_ring is
> NULL here - but PTR_ERR() apparently returns 0 in that case. So this
> function ends up returning no error.
Yes, IS_ERR_OR_NULL is evil for this very reason and should be avoided
where possible. There were discussions a while back about removing it,
or at least deprecating it because it causes more bugs (exactly of this
type) than it solves.
--
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-06-25 23:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 23:18 [PATCH v8 0/4] net: Add APM X-Gene SoC Ethernet driver support Iyappan Subramanian
2014-06-20 23:18 ` [PATCH v8 1/4] MAINTAINERS: Add entry for APM X-Gene SoC ethernet driver Iyappan Subramanian
[not found] ` <1403306296-26198-1-git-send-email-isubramanian-qTEPVZfXA3Y@public.gmane.org>
2014-06-20 23:18 ` [PATCH v8 2/4] Documentation: dts: Add bindings " Iyappan Subramanian
2014-06-20 23:18 ` [PATCH v8 3/4] " Iyappan Subramanian
2014-06-20 23:18 ` [PATCH v8 4/4] drivers: net: Add APM X-Gene SoC ethernet driver support Iyappan Subramanian
[not found] ` <1403306296-26198-5-git-send-email-isubramanian-qTEPVZfXA3Y@public.gmane.org>
2014-06-25 4:29 ` Dann Frazier
2014-06-25 16:40 ` Mark Salter
[not found] ` <CALdTtnvHt5mYMC3619E4F3KK0jPOw7mCpKE6bTn0Um6fdZ4rbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-06-25 23:04 ` Russell King - ARM Linux [this message]
2014-07-09 22:39 ` Iyappan Subramanian
2014-06-25 5:34 ` David Miller
[not found] ` <20140624.223442.1599243407487139839.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2014-07-09 22:38 ` Iyappan Subramanian
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=20140625230450.GO32514@n2100.arm.linux.org.uk \
--to=linux-lfz/pmaqli7xmaaqvzeohq@public.gmane.org \
--cc=dann.frazier-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=isubramanian-qTEPVZfXA3Y@public.gmane.org \
--cc=jcm-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=kchudgar-qTEPVZfXA3Y@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=patches-qTEPVZfXA3Y@public.gmane.org \
--cc=rapatel-qTEPVZfXA3Y@public.gmane.org \
/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).