From: Baolin Wang <baolin.wang@linaro.org>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, broonie@kernel.org,
baolin.wang@linaro.org
Subject: [PATCH] mm: dmapool: Check the dma pool name
Date: Wed, 30 May 2018 19:28:43 +0800 [thread overview]
Message-ID: <59623b15001e5a20ac32b1a393db88722be2e718.1527679621.git.baolin.wang@linaro.org> (raw)
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
next reply other threads:[~2018-05-30 11:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-30 11:28 Baolin Wang [this message]
2018-05-30 12:01 ` [PATCH] mm: dmapool: Check the dma pool name 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
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=59623b15001e5a20ac32b1a393db88722be2e718.1527679621.git.baolin.wang@linaro.org \
--to=baolin.wang@linaro.org \
--cc=arnd@arndb.de \
--cc=broonie@kernel.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: 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;
as well as URLs for NNTP newsgroup(s).