linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: dmapool: Check the dma pool name
@ 2018-05-30 11:28 Baolin Wang
  2018-05-30 12:01 ` Matthew Wilcox
  0 siblings, 1 reply; 6+ messages in thread
From: Baolin Wang @ 2018-05-30 11:28 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-kernel, arnd, broonie, baolin.wang

It will be crash if we pass one NULL name when creating one dma pool,
so we should check the passing name when copy it to dma pool.

Moreover this patch replaces kmalloc_node() with kzalloc_node() to make
sure the name array of dma pool is initialized in case the passing name
is NULL.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 mm/dmapool.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index 4d90a64..349f13d 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -155,11 +155,12 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
 	else if ((boundary < size) || (boundary & (boundary - 1)))
 		return NULL;
 
-	retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, dev_to_node(dev));
+	retval = kzalloc_node(sizeof(*retval), GFP_KERNEL, dev_to_node(dev));
 	if (!retval)
 		return retval;
 
-	strlcpy(retval->name, name, sizeof(retval->name));
+	if (name)
+		strlcpy(retval->name, name, sizeof(retval->name));
 
 	retval->dev = dev;
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-31  2:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-30 11:28 [PATCH] mm: dmapool: Check the dma pool name Baolin Wang
2018-05-30 12:01 ` Matthew Wilcox
2018-05-30 12:14   ` Baolin Wang
2018-05-30 15:13     ` Matthew Wilcox
2018-05-30 15:41       ` Matthew Wilcox
2018-05-31  2:34         ` Baolin Wang

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).