lkml.org 
[lkml]   [2018]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm: dmapool: Check the dma pool name
Date
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
\
 
 \ /
  Last update: 2018-05-30 13:29    [W:0.042 / U:1.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site