* [PATCH] regmap: debugfs: fix possbile NULL pointer dereference
@ 2014-09-28 3:35 Xiubo Li
2014-09-28 10:45 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Xiubo Li @ 2014-09-28 3:35 UTC (permalink / raw)
To: broonie; +Cc: linux-kernel, Xiubo Li
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: Xiubo Li <Li.Xiubo@freescale.com>
---
drivers/base/regmap/regmap-debugfs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 0c94b66..5799a0b 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -473,6 +473,7 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
{
struct rb_node *next;
struct regmap_range_node *range_node;
+ const char *devname = "dummy";
/* If we don't have the debugfs root yet, postpone init */
if (!regmap_debugfs_root) {
@@ -491,12 +492,15 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
INIT_LIST_HEAD(&map->debugfs_off_cache);
mutex_init(&map->cache_lock);
+ if (map->dev)
+ devname = dev_name(map->dev);
+
if (name) {
map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
- dev_name(map->dev), name);
+ devname, name);
name = map->debugfs_name;
} else {
- name = dev_name(map->dev);
+ name = devname;
}
map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
--
2.1.0.27.g96db324
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] regmap: debugfs: fix possbile NULL pointer dereference
2014-09-28 3:35 [PATCH] regmap: debugfs: fix possbile NULL pointer dereference Xiubo Li
@ 2014-09-28 10:45 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-09-28 10:45 UTC (permalink / raw)
To: Xiubo Li; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 236 bytes --]
On Sun, Sep 28, 2014 at 11:35:25AM +0800, Xiubo Li wrote:
> 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.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-28 10:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-28 3:35 [PATCH] regmap: debugfs: fix possbile NULL pointer dereference Xiubo Li
2014-09-28 10:45 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®