All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regmap: debugfs: Free the previous allocated debugfs_name buffer
@ 2022-01-06 17:15 Fabio Estevam
  2022-01-06 17:31 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2022-01-06 17:15 UTC (permalink / raw)
  To: broonie; +Cc: matthias.schiffer, linux-kernel, Fabio Estevam

The following error message is seen when booting an imx6q-sabresd:

debugfs: Directory 'dummy-iomuxc-gpr@20e0000' with parent 'regmap' already present!

By inspecting the duplicate directory name: 

[    0.274418] platform panel: Fixing up cyclic dependency with ldb
[    0.276896] ************ 1: devname is dummy
[    0.276926] ************ 2: name is iomuxc-gpr@20e0000
[    0.276951] ************ 3: Forming the final name
[    0.276979] ************ 3a: Name from map->debugfs_name dummy-iomuxc-gpr@20e0000
[    0.277001] ************ 4: name is dummy-iomuxc-gpr@20e0000
[    0.277022] ************ 5: Final name is dummy-iomuxc-gpr@20e0000
[    0.277746] No ATAGs?
[    0.278355] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[    0.278469] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.282007] ********** gpr succeeded
[    0.282042] ************ 1: devname is 20e0000.pinctrl
[    0.282070] ************ 2: name is gpr
[    0.282093] ************ 3a: Name from map->debugfs_name dummy-iomuxc-gpr@20e0000
[    0.282115] ************ 4: name is dummy-iomuxc-gpr@20e0000
[    0.282138] ************ 5: Final name is dummy-iomuxc-gpr@20e0000
[    0.282185] debugfs: Directory 'dummy-iomuxc-gpr@20e0000' with parent 'regmap' already present!


The 'dummy-iomuxc-gpr@20e0000' name is caused by a non-freed map->debugfs_name
buffer.

After calling kfree(map->debugfs_name), no more duplicate naming is seen:

After:

[    0.257135] platform 2800000.ipu: Fixing up cyclic dependency with 120000.hdmi
[    0.257460] platform 2800000.ipu: Fixing up cyclic dependency with 20e0000.iomuxc-gpr:ipu2_csi1_mux
[    0.257782] platform 2800000.ipu: Fixing up cyclic dependency with 21dc000.mipi
[    0.273536] platform panel: Fixing up cyclic dependency with ldb
[    0.276013] ************ 1: devname is dummy
[    0.276043] ************ 2: name is iomuxc-gpr@20e0000
[    0.276067] ************ 3: Forming the final name
[    0.276097] ************ 3a: Name from map->debugfs_name dummy-iomuxc-gpr@20e0000
[    0.276119] ************ 4: name is dummy-iomuxc-gpr@20e0000
[    0.276141] ************ 5: Final name is dummy-iomuxc-gpr@20e0000
[    0.276859] No ATAGs?
[    0.277468] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[    0.277580] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.281122] ********** gpr succeeded
[    0.281156] ************ 1: devname is 20e0000.pinctrl
[    0.281184] ************ 2: name is gpr
[    0.281206] ************ 3a: Name from map->debugfs_name 20e0000.pinctrl
[    0.281228] ************ 4: name is 20e0000.pinctrl
[    0.281251] ************ 5: Final name is 20e0000.pinctrl

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/base/regmap/regmap-debugfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index ad684d37c2da..18f0c7223082 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -589,6 +589,7 @@ void regmap_debugfs_init(struct regmap *map)
 				return;
 		}
 		name = map->debugfs_name;
+		kfree(map->debugfs_name);
 	} else {
 		name = devname;
 	}
@@ -600,6 +601,7 @@ void regmap_debugfs_init(struct regmap *map)
 		if (!map->debugfs_name)
 				return;
 		name = map->debugfs_name;
+		kfree(map->debugfs_name);
 		dummy_index++;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] regmap: debugfs: Free the previous allocated debugfs_name buffer
  2022-01-06 17:15 Fabio Estevam
@ 2022-01-06 17:31 ` Mark Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-01-06 17:31 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: matthias.schiffer, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]

On Thu, Jan 06, 2022 at 02:15:37PM -0300, Fabio Estevam wrote:

> debugfs: Directory 'dummy-iomuxc-gpr@20e0000' with parent 'regmap' already present!
> 
> By inspecting the duplicate directory name: 
> 
> [    0.274418] platform panel: Fixing up cyclic dependency with ldb
> [    0.276896] ************ 1: devname is dummy
> [    0.276926] ************ 2: name is iomuxc-gpr@20e0000

It's quite hard to read these kernel logs and tie them into anything -
they're fairly verbose and weirdly formatted with all the *********s.

> +++ b/drivers/base/regmap/regmap-debugfs.c
> @@ -589,6 +589,7 @@ void regmap_debugfs_init(struct regmap *map)
>  				return;
>  		}
>  		name = map->debugfs_name;
> +		kfree(map->debugfs_name);
>  	} else {
>  		name = devname;
>  	}
> @@ -600,6 +601,7 @@ void regmap_debugfs_init(struct regmap *map)
>  		if (!map->debugfs_name)
>  				return;
>  		name = map->debugfs_name;
> +		kfree(map->debugfs_name);

This is fairly clearly introducing a use after free bug - we've taken a
copy of map->debugfs_name in name then immediately free map->debugfs_name
so any use of name will be referencing freed memory.  If this works it
will be because something went and zeroed the memory, it's just as
likely to cause us to crash.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] regmap: debugfs: Free the previous allocated debugfs_name buffer
@ 2022-01-09  7:51 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-01-09  7:51 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 19412 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20220106171537.3091643-1-festevam@gmail.com>
References: <20220106171537.3091643-1-festevam@gmail.com>
TO: Fabio Estevam <festevam@gmail.com>
TO: broonie(a)kernel.org
CC: matthias.schiffer(a)ew.tq-group.com
CC: linux-kernel(a)vger.kernel.org
CC: Fabio Estevam <festevam@gmail.com>

Hi Fabio,

I love your patch! Perhaps something to improve:

[auto build test WARNING on broonie-regmap/for-next]
[also build test WARNING on v5.16-rc8 next-20220107]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Fabio-Estevam/regmap-debugfs-Free-the-previous-allocated-debugfs_name-buffer/20220107-011724
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: arm-randconfig-c002-20220107 (https://download.01.org/0day-ci/archive/20220109/202201091558.ITRbIvGW-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167bfe64a4c5dd4eb3f7a58e24f4cba76f5ac2)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/0day-ci/linux/commit/7de11921ba557466d696129b8cdc0a6176e763f1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Fabio-Estevam/regmap-debugfs-Free-the-previous-allocated-debugfs_name-buffer/20220107-011724
        git checkout 7de11921ba557466d696129b8cdc0a6176e763f1
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
           ^
   include/linux/compiler_types.h:335:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:323:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:307:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   drivers/net/wireguard/device.c:145:15: note: Assuming 'family' is equal to 2
           if (unlikely(family != AF_INET && family != AF_INET6)) {
                        ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   drivers/net/wireguard/device.c:145:33: note: Left side of '&&' is false
           if (unlikely(family != AF_INET && family != AF_INET6)) {
                                          ^
   drivers/net/wireguard/device.c:145:2: note: Taking false branch
           if (unlikely(family != AF_INET && family != AF_INET6)) {
           ^
   drivers/net/wireguard/device.c:152:8: note: Assuming the condition is false
           mtu = skb_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu;
                 ^~~~~~~~~~~~
   drivers/net/wireguard/device.c:152:8: note: '?' condition is false
   drivers/net/wireguard/device.c:154:2: note: Calling '__skb_queue_head_init'
           __skb_queue_head_init(&packets);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/wireguard/device.c:154:2: note: Returning from '__skb_queue_head_init'
           __skb_queue_head_init(&packets);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/wireguard/device.c:155:6: note: Assuming the condition is true
           if (!skb_is_gso(skb)) {
               ^~~~~~~~~~~~~~~~
   drivers/net/wireguard/device.c:155:2: note: Taking true branch
           if (!skb_is_gso(skb)) {
           ^
   drivers/net/wireguard/device.c:168:26: note: 'skb' is non-null
           skb_list_walk_safe(skb, skb, next) {
                                   ^
   include/linux/skbuff.h:1559:38: note: expanded from macro 'skb_list_walk_safe'
           for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb);  \
                                               ^~~
   drivers/net/wireguard/device.c:168:2: note: '?' condition is true
           skb_list_walk_safe(skb, skb, next) {
           ^
   include/linux/skbuff.h:1559:37: note: expanded from macro 'skb_list_walk_safe'
           for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb);  \
                                              ^
   drivers/net/wireguard/device.c:168:2: note: Loop condition is true.  Entering loop body
           skb_list_walk_safe(skb, skb, next) {
           ^
   include/linux/skbuff.h:1559:2: note: expanded from macro 'skb_list_walk_safe'
           for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb);  \
           ^
   drivers/net/wireguard/device.c:172:17: note: 'skb' is non-null
                   if (unlikely(!skb))
                                 ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   drivers/net/wireguard/device.c:172:3: note: Taking false branch
                   if (unlikely(!skb))
                   ^
   drivers/net/wireguard/device.c:182:3: note: Calling '__skb_queue_tail'
                   __skb_queue_tail(&packets, skb);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:2118:2: note: Calling '__skb_queue_before'
           __skb_queue_before(list, (struct sk_buff *)list, newsk);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:2085:2: note: 2nd function call argument is an uninitialized value
           __skb_insert(newsk, next->prev, next, list);
           ^                   ~~~~~~~~~~
   1 warning generated.
   drivers/base/regmap/regcache.c:137:7: warning: Dereference of null pointer [clang-analyzer-core.NullDereference]
                   if (config->reg_defaults[i].reg % map->reg_stride)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regcache.c:121:6: note: Assuming field 'cache_type' is not equal to REGCACHE_NONE
           if (map->cache_type == REGCACHE_NONE) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regcache.c:121:2: note: Taking false branch
           if (map->cache_type == REGCACHE_NONE) {
           ^
   drivers/base/regmap/regcache.c:130:6: note: Assuming field 'reg_defaults' is null
           if (config->reg_defaults && !config->num_reg_defaults) {
               ^~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regcache.c:130:27: note: Left side of '&&' is false
           if (config->reg_defaults && !config->num_reg_defaults) {
                                    ^
   drivers/base/regmap/regcache.c:136:14: note: Assuming 'i' is < field 'num_reg_defaults'
           for (i = 0; i < config->num_reg_defaults; i++)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regcache.c:136:2: note: Loop condition is true.  Entering loop body
           for (i = 0; i < config->num_reg_defaults; i++)
           ^
   drivers/base/regmap/regcache.c:137:7: note: Dereference of null pointer
                   if (config->reg_defaults[i].reg % map->reg_stride)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   3 warnings generated.
>> drivers/base/regmap/regmap-debugfs.c:597:7: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
           if (!strcmp(name, "dummy")) {
                ^
   drivers/base/regmap/regmap-debugfs.c:688:2: note: Loop condition is true.  Entering loop body
           list_for_each_entry_safe(node, tmp, &regmap_debugfs_early_list, link) {
           ^
   include/linux/list.h:717:2: note: expanded from macro 'list_for_each_entry_safe'
           for (pos = list_first_entry(head, typeof(*pos), member),        \
           ^
   drivers/base/regmap/regmap-debugfs.c:689:3: note: Calling 'regmap_debugfs_init'
                   regmap_debugfs_init(node->map);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:560:6: note: Assuming field 'debugfs_disable' is false
           if (map->debugfs_disable) {
               ^~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:560:2: note: Taking false branch
           if (map->debugfs_disable) {
           ^
   drivers/base/regmap/regmap-debugfs.c:566:6: note: Assuming 'regmap_debugfs_root' is non-null
           if (!regmap_debugfs_root) {
               ^~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:566:2: note: Taking false branch
           if (!regmap_debugfs_root) {
           ^
   drivers/base/regmap/regmap-debugfs.c:579:2: note: Loop condition is false.  Exiting loop
           mutex_init(&map->cache_lock);
           ^
   include/linux/mutex.h:101:32: note: expanded from macro 'mutex_init'
   #define mutex_init(mutex)                                               \
                                                                           ^
   drivers/base/regmap/regmap-debugfs.c:581:6: note: Assuming field 'dev' is null
           if (map->dev)
               ^~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:581:2: note: Taking false branch
           if (map->dev)
           ^
   drivers/base/regmap/regmap-debugfs.c:584:6: note: Assuming 'name' is non-null
           if (name) {
               ^~~~
   drivers/base/regmap/regmap-debugfs.c:584:2: note: Taking true branch
           if (name) {
           ^
   drivers/base/regmap/regmap-debugfs.c:585:7: note: Assuming field 'debugfs_name' is non-null
                   if (!map->debugfs_name) {
                       ^~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:585:3: note: Taking false branch
                   if (!map->debugfs_name) {
                   ^
   drivers/base/regmap/regmap-debugfs.c:592:3: note: Memory is released
                   kfree(map->debugfs_name);
                   ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:597:7: note: Use of memory after it is freed
           if (!strcmp(name, "dummy")) {
                ^      ~~~~
   drivers/base/regmap/regmap-debugfs.c:608:17: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
           map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
                          ^
   drivers/base/regmap/regmap-debugfs.c:688:2: note: Loop condition is true.  Entering loop body
           list_for_each_entry_safe(node, tmp, &regmap_debugfs_early_list, link) {
           ^
   include/linux/list.h:717:2: note: expanded from macro 'list_for_each_entry_safe'
           for (pos = list_first_entry(head, typeof(*pos), member),        \
           ^
   drivers/base/regmap/regmap-debugfs.c:689:3: note: Calling 'regmap_debugfs_init'
                   regmap_debugfs_init(node->map);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:560:6: note: Assuming field 'debugfs_disable' is false
           if (map->debugfs_disable) {
               ^~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:560:2: note: Taking false branch
           if (map->debugfs_disable) {
           ^
   drivers/base/regmap/regmap-debugfs.c:566:6: note: Assuming 'regmap_debugfs_root' is non-null
           if (!regmap_debugfs_root) {
               ^~~~~~~~~~~~~~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:566:2: note: Taking false branch
           if (!regmap_debugfs_root) {
           ^
   drivers/base/regmap/regmap-debugfs.c:579:2: note: Loop condition is false.  Exiting loop
           mutex_init(&map->cache_lock);
           ^
   include/linux/mutex.h:101:32: note: expanded from macro 'mutex_init'
   #define mutex_init(mutex)                                               \
                                                                           ^
   drivers/base/regmap/regmap-debugfs.c:581:6: note: Assuming field 'dev' is null
           if (map->dev)
               ^~~~~~~~
   drivers/base/regmap/regmap-debugfs.c:581:2: note: Taking false branch
           if (map->dev)
           ^
   drivers/base/regmap/regmap-debugfs.c:584:6: note: Assuming 'name' is null
           if (name) {
               ^~~~
   drivers/base/regmap/regmap-debugfs.c:584:2: note: Taking false branch
           if (name) {
           ^
   drivers/base/regmap/regmap-debugfs.c:597:2: note: Taking true branch
           if (!strcmp(name, "dummy")) {
           ^
   drivers/base/regmap/regmap-debugfs.c:601:7: note: Assuming field 'debugfs_name' is non-null
                   if (!map->debugfs_name)

vim +597 drivers/base/regmap/regmap-debugfs.c

d3dc5430d68fb9 Richard Fitzgerald  2015-06-23  545  
94cc89eb8fa503 Charles Keepax      2020-09-17  546  void regmap_debugfs_init(struct regmap *map)
31244e396fa9e4 Mark Brown          2011-07-20  547  {
4b020b3f9ba2af Mark Brown          2012-10-03  548  	struct rb_node *next;
4b020b3f9ba2af Mark Brown          2012-10-03  549  	struct regmap_range_node *range_node;
2c98e0c1cc6b8e Xiubo Li            2014-09-28  550  	const char *devname = "dummy";
94cc89eb8fa503 Charles Keepax      2020-09-17  551  	const char *name = map->name;
4b020b3f9ba2af Mark Brown          2012-10-03  552  
078711d7f88d33 Bartosz Golaszewski 2017-12-22  553  	/*
078711d7f88d33 Bartosz Golaszewski 2017-12-22  554  	 * Userspace can initiate reads from the hardware over debugfs.
078711d7f88d33 Bartosz Golaszewski 2017-12-22  555  	 * Normally internal regmap structures and buffers are protected with
078711d7f88d33 Bartosz Golaszewski 2017-12-22  556  	 * a mutex or a spinlock, but if the regmap owner decided to disable
078711d7f88d33 Bartosz Golaszewski 2017-12-22  557  	 * all locking mechanisms, this is no longer the case. For safety:
078711d7f88d33 Bartosz Golaszewski 2017-12-22  558  	 * don't create the debugfs entries if locking is disabled.
078711d7f88d33 Bartosz Golaszewski 2017-12-22  559  	 */
a5ba91c380b8bc Bartosz Golaszewski 2017-12-21  560  	if (map->debugfs_disable) {
a5ba91c380b8bc Bartosz Golaszewski 2017-12-21  561  		dev_dbg(map->dev, "regmap locking disabled - not creating debugfs entries\n");
72465736adf2aa Mark Brown          2017-12-12  562  		return;
a5ba91c380b8bc Bartosz Golaszewski 2017-12-21  563  	}
72465736adf2aa Mark Brown          2017-12-12  564  
a52eaeb1898bc0 Tero Kristo         2013-10-24  565  	/* If we don't have the debugfs root yet, postpone init */
a52eaeb1898bc0 Tero Kristo         2013-10-24  566  	if (!regmap_debugfs_root) {
a52eaeb1898bc0 Tero Kristo         2013-10-24  567  		struct regmap_debugfs_node *node;
a52eaeb1898bc0 Tero Kristo         2013-10-24  568  		node = kzalloc(sizeof(*node), GFP_KERNEL);
a52eaeb1898bc0 Tero Kristo         2013-10-24  569  		if (!node)
a52eaeb1898bc0 Tero Kristo         2013-10-24  570  			return;
a52eaeb1898bc0 Tero Kristo         2013-10-24  571  		node->map = map;
a52eaeb1898bc0 Tero Kristo         2013-10-24  572  		mutex_lock(&regmap_debugfs_early_lock);
a52eaeb1898bc0 Tero Kristo         2013-10-24  573  		list_add(&node->link, &regmap_debugfs_early_list);
a52eaeb1898bc0 Tero Kristo         2013-10-24  574  		mutex_unlock(&regmap_debugfs_early_lock);
a52eaeb1898bc0 Tero Kristo         2013-10-24  575  		return;
a52eaeb1898bc0 Tero Kristo         2013-10-24  576  	}
a52eaeb1898bc0 Tero Kristo         2013-10-24  577  
5166b7c006eeb4 Mark Brown          2012-12-11  578  	INIT_LIST_HEAD(&map->debugfs_off_cache);
065b4c587557dc Dimitris Papastamos 2013-02-20  579  	mutex_init(&map->cache_lock);
5166b7c006eeb4 Mark Brown          2012-12-11  580  
2c98e0c1cc6b8e Xiubo Li            2014-09-28  581  	if (map->dev)
2c98e0c1cc6b8e Xiubo Li            2014-09-28  582  		devname = dev_name(map->dev);
2c98e0c1cc6b8e Xiubo Li            2014-09-28  583  
d3c242e1f22f5d Stephen Warren      2012-04-04  584  	if (name) {
cffa4b2122f5f3 Xiaolei Wang        2020-12-29  585  		if (!map->debugfs_name) {
d3c242e1f22f5d Stephen Warren      2012-04-04  586  			map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
2c98e0c1cc6b8e Xiubo Li            2014-09-28  587  					      devname, name);
cffa4b2122f5f3 Xiaolei Wang        2020-12-29  588  			if (!map->debugfs_name)
cffa4b2122f5f3 Xiaolei Wang        2020-12-29  589  				return;
cffa4b2122f5f3 Xiaolei Wang        2020-12-29  590  		}
d3c242e1f22f5d Stephen Warren      2012-04-04  591  		name = map->debugfs_name;
7de11921ba5574 Fabio Estevam       2022-01-06  592  		kfree(map->debugfs_name);
d3c242e1f22f5d Stephen Warren      2012-04-04  593  	} else {
2c98e0c1cc6b8e Xiubo Li            2014-09-28  594  		name = devname;
d3c242e1f22f5d Stephen Warren      2012-04-04  595  	}
d3c242e1f22f5d Stephen Warren      2012-04-04  596  
a430ab205d29e7 Fabio Estevam       2018-03-05 @597  	if (!strcmp(name, "dummy")) {
2899872b627e99 Daniel Baluta       2019-05-17  598  		kfree(map->debugfs_name);
46589e9c753b7c Mark Brown          2018-03-05  599  		map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
46589e9c753b7c Mark Brown          2018-03-05  600  						dummy_index);
cffa4b2122f5f3 Xiaolei Wang        2020-12-29  601  		if (!map->debugfs_name)
cffa4b2122f5f3 Xiaolei Wang        2020-12-29  602  				return;
46589e9c753b7c Mark Brown          2018-03-05  603  		name = map->debugfs_name;
7de11921ba5574 Fabio Estevam       2022-01-06  604  		kfree(map->debugfs_name);
a430ab205d29e7 Fabio Estevam       2018-03-05  605  		dummy_index++;
a430ab205d29e7 Fabio Estevam       2018-03-05  606  	}
a430ab205d29e7 Fabio Estevam       2018-03-05  607  
d3c242e1f22f5d Stephen Warren      2012-04-04  608  	map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
31244e396fa9e4 Mark Brown          2011-07-20  609  
f0c2319f9f1967 Dimitris Papastamos 2012-02-22  610  	debugfs_create_file("name", 0400, map->debugfs,
f0c2319f9f1967 Dimitris Papastamos 2012-02-22  611  			    map, &regmap_name_fops);
f0c2319f9f1967 Dimitris Papastamos 2012-02-22  612  
065b4c587557dc Dimitris Papastamos 2013-02-20  613  	debugfs_create_file("range", 0400, map->debugfs,
065b4c587557dc Dimitris Papastamos 2013-02-20  614  			    map, &regmap_reg_ranges_fops);
065b4c587557dc Dimitris Papastamos 2013-02-20  615  
676970da5cf6fe Pawel Moll          2014-01-30  616  	if (map->max_register || regmap_readable(map, 0)) {
ffff7a12ace24c Markus Pargmann     2014-09-08  617  		umode_t registers_mode;
ffff7a12ace24c Markus Pargmann     2014-09-08  618  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-09  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-09  7:51 [PATCH] regmap: debugfs: Free the previous allocated debugfs_name buffer kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-01-06 17:15 Fabio Estevam
2022-01-06 17:31 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.