Commit a3f3ff38 authored by Xiubo Li's avatar Xiubo Li Committed by Zefan Li

regmap: debugfs: fix possbile NULL pointer dereference

commit 2c98e0c1 upstream.

If 'map->dev' is NULL and there will lead dev_name() to be NULL pointer
dereference. So before dev_name(), we need to have check of the map->dev
pionter.

We also should make sure that the 'name' pointer shouldn't be NULL for
debugfs_create_dir(). So here using one default "dummy" debugfs name when
the 'name' pointer and 'map->dev' are both NULL.
Signed-off-by: default avatarXiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
[lizf: Backported to 3.4: dev_name() is passed to debugfs_create_dir() in 3.4]
Signed-off-by: default avatarZefan Li <lizefan@huawei.com>
parent d3c4aba0
......@@ -244,7 +244,12 @@ static const struct file_operations regmap_access_fops = {
void regmap_debugfs_init(struct regmap *map)
{
map->debugfs = debugfs_create_dir(dev_name(map->dev),
const char *devname = "dummy";
if (map->dev)
devname = dev_name(map->dev);
map->debugfs = debugfs_create_dir(devname,
regmap_debugfs_root);
if (!map->debugfs) {
dev_warn(map->dev, "Failed to create debugfs directory\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment