From: Xi Wang <xi.wang@gmail.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xi Wang <xi.wang@gmail.com> Subject: [PATCH] mm: fix NULL checking in dma_pool_create() Date: Mon, 5 Nov 2012 01:46:36 -0500 [thread overview] Message-ID: <1352097996-25808-1-git-send-email-xi.wang@gmail.com> (raw) First, `dev' is dereferenced in dev_to_node(dev), suggesting that it must be non-null. Later `dev' is checked against NULL, suggesting the opposite. This patch adds a NULL check before its use. Signed-off-by: Xi Wang <xi.wang@gmail.com> --- mm/dmapool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/dmapool.c b/mm/dmapool.c index c5ab33b..afbf88e 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 = dev ? dev_to_node(dev) : -1; + + retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, node); if (!retval) return retval; -- 1.7.10.4
WARNING: multiple messages have this Message-ID (diff)
From: Xi Wang <xi.wang@gmail.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xi Wang <xi.wang@gmail.com> Subject: [PATCH] mm: fix NULL checking in dma_pool_create() Date: Mon, 5 Nov 2012 01:46:36 -0500 [thread overview] Message-ID: <1352097996-25808-1-git-send-email-xi.wang@gmail.com> (raw) First, `dev' is dereferenced in dev_to_node(dev), suggesting that it must be non-null. Later `dev' is checked against NULL, suggesting the opposite. This patch adds a NULL check before its use. Signed-off-by: Xi Wang <xi.wang@gmail.com> --- mm/dmapool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/dmapool.c b/mm/dmapool.c index c5ab33b..afbf88e 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 = dev ? dev_to_node(dev) : -1; + + retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, node); if (!retval) return retval; -- 1.7.10.4 -- 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 reply other threads:[~2012-11-05 6:46 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-05 6:46 Xi Wang [this message] 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:37 ` Andrew Morton 2012-11-05 20:50 ` Xi Wang 2012-11-05 20:50 ` Xi Wang 2012-11-05 21:26 ` Andrew Morton 2012-11-05 21:26 ` Andrew Morton 2012-11-06 20:48 ` Xi Wang 2012-11-06 20:48 ` Xi Wang 2012-11-13 21:39 ` [PATCH v2] mm: fix null dev " Xi Wang 2012-11-13 21:39 ` Xi Wang 2012-11-13 23:01 ` David Rientjes 2012-11-13 23:01 ` David Rientjes 2012-11-14 0:47 ` Andrew Morton 2012-11-14 0:47 ` Andrew Morton 2012-11-14 0:58 ` Andrew Morton 2012-11-14 0:58 ` Andrew Morton 2012-11-14 5:50 ` Xi Wang 2012-11-14 5:50 ` Xi Wang 2012-11-14 14:17 ` Felipe Balbi 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=1352097996-25808-1-git-send-email-xi.wang@gmail.com \ --to=xi.wang@gmail.com \ --cc=akpm@linux-foundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.