From: David Rientjes <rientjes@google.com>
To: Xi Wang <xi.wang@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm: fix null dev in dma_pool_create()
Date: Tue, 13 Nov 2012 15:01:34 -0800 (PST) [thread overview]
Message-ID: <alpine.DEB.2.00.1211131458440.17623@chino.kir.corp.google.com> (raw)
In-Reply-To: <50A2BE19.7000604@gmail.com>
On Tue, 13 Nov 2012, Xi Wang wrote:
> diff --git a/mm/dmapool.c b/mm/dmapool.c
> index c5ab33b..bf7f8f0 100644
> --- a/mm/dmapool.c
> +++ b/mm/dmapool.c
> @@ -135,6 +135,7 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
> {
> struct dma_pool *retval;
> size_t allocation;
> + int node;
>
> if (align == 0) {
> align = 1;
> @@ -159,7 +160,9 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
> return NULL;
> }
>
> - retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, dev_to_node(dev));
> + node = WARN_ON(!dev) ? -1 : dev_to_node(dev);
> +
> + retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, node);
> if (!retval)
> return retval;
>
Begs the question why we don't just do something like this generically?
---
diff --git a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -718,7 +718,7 @@ int dev_set_name(struct device *dev, const char *name, ...);
#ifdef CONFIG_NUMA
static inline int dev_to_node(struct device *dev)
{
- return dev->numa_node;
+ return WARN_ON(!dev) ? NUMA_NO_NODE : dev->numa_node;
}
static inline void set_dev_node(struct device *dev, int node)
{
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-11-13 23:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-05 6:46 [PATCH] mm: fix NULL checking " Xi Wang
2012-11-05 20:37 ` Andrew Morton
2012-11-05 20:50 ` Xi Wang
2012-11-05 21:26 ` Andrew Morton
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 [this message]
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=alpine.DEB.2.00.1211131458440.17623@chino.kir.corp.google.com \
--to=rientjes@google.com \
--cc=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