From: Andrew Morton <akpm@linux-foundation.org>
To: Xi Wang <xi.wang@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: fix NULL checking in dma_pool_create()
Date: Mon, 5 Nov 2012 13:26:51 -0800 [thread overview]
Message-ID: <20121105132651.f52549b6.akpm@linux-foundation.org> (raw)
In-Reply-To: <50982698.7050605@gmail.com>
On Mon, 05 Nov 2012 15:50:32 -0500
Xi Wang <xi.wang@gmail.com> wrote:
> On 11/5/12 3:37 PM, Andrew Morton wrote:
> >
> > Well, the dma_pool_create() kerneldoc does not describe dev==NULL to be
> > acceptable usage and given the lack of oops reports, we can assume that
> > no code is calling this function with dev==NULL.
> >
> > So I think we can just remove the code which handles dev==NULL?
>
> Actually, a quick grep gives the following...
>
> arch/arm/mach-s3c64xx/dma.c:731: dma_pool = dma_pool_create("DMA-LLI", NULL, sizeof(struct pl080s_lli), 16, 0);
> drivers/usb/gadget/amd5536udc.c:3136: dev->data_requests = dma_pool_create("data_requests", NULL,
> drivers/usb/gadget/amd5536udc.c:3148: dev->stp_requests = dma_pool_create("setup requests", NULL,
> drivers/net/wan/ixp4xx_hss.c:973: if (!(dma_pool = dma_pool_create(DRV_NAME, NULL,
> drivers/net/ethernet/xscale/ixp4xx_eth.c:1106: if (!(dma_pool = dma_pool_create(DRV_NAME, NULL,
>
OK, so it seems that those drivers have never been tested on a
CONFIG_NUMA kernel. whee.
So we have a large amount of code here which ostensibly supports
dev==NULL but which has not been well tested. Take a look at
dma_alloc_coherent(), dma_free_coherent() - are they safe? Unobvious.
dmam_pool_destroy() will clearly cause an oops:
devres_destroy()
->devres_remove()
->spin_lock_irqsave(&dev->devres_lock, flags);
So what to do?
I'm thinking we should disallow dev==NULL. We have a lot of code in
mm/dmapool.c which _attempts_ to support this case, but is largely
untested and obviously isn't working. I don't think it's a good idea
to try to fix up and then support this case on behalf of a handful of
scruffy drivers. It would be better to fix the drivers, then simplify
the core code. drivers/usb/gadget/amd5536udc.c can probably use
dev->gadget.dev and drivers/net/wan/ixp4xx_hss.c can probably use
port->netdev->dev, etc.
So how about we add a WARN_ON_ONCE(dev == NULL), notify the driver maintainers
and later we can remove all that mm/dmapool.c code which is trying to
handle dev==NULL?
next prev parent reply other threads:[~2012-11-05 21:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-05 6:46 [PATCH] mm: fix NULL checking in dma_pool_create() Xi Wang
2012-11-05 20:37 ` Andrew Morton
2012-11-05 20:50 ` Xi Wang
2012-11-05 21:26 ` Andrew Morton [this message]
2012-11-06 20:48 ` Xi Wang
2012-11-13 21:39 ` [PATCH v2] mm: fix null dev " Xi Wang
2012-11-13 23:01 ` David Rientjes
2012-11-14 0:47 ` Andrew Morton
2012-11-14 0:58 ` Andrew Morton
2012-11-14 5:50 ` Xi Wang
2012-11-14 14:17 ` Felipe Balbi
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=20121105132651.f52549b6.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=xi.wang@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).