CC: [email protected] CC: [email protected] In-Reply-To: <[email protected]> References: <[email protected]> TO: Fabio Estevam <[email protected]> TO: [email protected] CC: [email protected] CC: [email protected] CC: Fabio Estevam <[email protected]>
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/[email protected]/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 <[email protected]> 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, ®map_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, ®map_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(®map_debugfs_early_lock); a52eaeb1898bc0 Tero Kristo 2013-10-24 573 list_add(&node->link, ®map_debugfs_early_list); a52eaeb1898bc0 Tero Kristo 2013-10-24 574 mutex_unlock(®map_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, ®map_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, ®map_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/[email protected] _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
