[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <59623b15001e5a20ac32b1a393db88722be2e718.1527679621.git.baolin.wang@linaro.org>
Date: Wed, 30 May 2018 19:28:43 +0800
From: Baolin Wang <baolin.wang@...aro.org>
To: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org, arnd@...db.de, broonie@...nel.org,
baolin.wang@...aro.org
Subject: [PATCH] mm: dmapool: Check the dma pool name
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@...aro.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
Powered by blists - more mailing lists